OMNeT++ error: could not be resolved

OMNeT++ error: could not be resolved

我是 OMNeT++ 的新手,我正在学习 OMNeT++ now.I 想 运行 根据教程进行 tictoc 模拟。首先我无法创建项目,它说 Error:CoreException.有人告诉我把文本文件编码改成UTF-8.Then问题是solved.But当我添加一个新的C++源文件时,又出现了一个问题:无法解决。

#include <string.h>
#include <omnetpp.h>
class Txc1 : public cSimpleModule
{
   protected:

   virtual void initialize();
   virtual void handleMessage(cMessage *msg);
};

Define_Module(Txc1);

void Txc1::initialize()
{
    // Am I Tic or Toc?
    if (strcmp("tic", getName()) == 0)
    {

        cMessage *msg = new cMessage("tictocMsg");
        send(msg, "out");
    }
}

void Txc1::handleMessage(cMessage *msg)
{

    send(msg, "out");
}

cSimpleModule,Define_Module,cMessage...所有这些都无法解决。

但令人难以置信的是,当我点击菜单 运行->运行 时,我可以构建 project.And 作为 OMNeT++ 模拟,它 运行 normally.So 是改变文本文件编码确实导致了这个问题?我该如何解决?

您需要添加

using namespace omnetpp;

在 headers 之后,如果您希望在其中使用 类(cSimpleModulecMessage)而不使用 omnetpp:: 前缀。

创建自己的简单模块需要精通 C++。当然你可以边做边学,但这个错误不是 OMNeT++ 特有的,这是一个普遍的 C++ 编程错误。