在 initialize() 中设置新的门连接

Setting up new gate connections in initialize()

我希望在我的简单模块 class 文件中的 initialize() 内增加我的门矢量的大小,并连接到另一个节点。

cModule *nodeA= getSimulation()->getModule(0);
cModule *nodeB= getSimulation()->getModule(1);
nodeA->gate("port$o")->connectTo(nodeB->gate("port$i"));

nodeAnodeB的gate vector已经满了,即gate vector的所有gate都已经分配完毕。在连接部分的 NED 文件中,我可以编写如下内容:

nodeA.port++ --> ned.IdealChannel --> nodeB.port++;

这允许我扩展门向量的大小并在节点之间建立连接。是否可以在 C++ 中做类似的事情?

不,不能使用 C++ 控制门向量的大小。