主要四个函数:
.h文件
#include <omnetpp.h> using namespace omnetpp; namespace sin { //包名,项目名 class Txc : public cSimpleModule { protected: virtual void initialize(); virtual void handleMessage(cMessage *msg); virtual void finish(); }; };
.cc文件
#include "Txc.h" namespace sin { Define_Module(Txc); void Txc::initialize() { if (par("sendInitialMessage").boolValue()) { cMessage *msg = new cMessage("tictocMsg"); send(msg, "out"); } } void Txc::handleMessage(cMessage *msg) { send(msg, "out"); } }; // namespace
原文:https://www.cnblogs.com/codinghard/p/11084968.html