txc2.cpp
来自「这是一个基于OMNeT++的仿真模型,编程语采用C」· C++ 代码 · 共 32 行
CPP
32 行
#include <string.h>
#include <omnetpp.h>
class Txc2 : public cSimpleModule
{
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};
Define_Module(Txc2);
void Txc2::initialize()
{
if (strcmp("tic", name()) == 0)
{
// The `ev' object works like `cout' in C++.
ev << "Sending initial message\n";
cMessage *msg = new cMessage("tictocMsg");
send(msg, "out");
}
}
void Txc2::handleMessage(cMessage *msg)
{
// msg->name() is name of the msg object, here it will be "tictocMsg".
ev << "Received message `" << msg->name() << "', sending it out again\n";
send(msg, "out");
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?