Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 omnetpp 中从 cPacket 输入 cMessage 类型转换?因为有些组件只接受 cPackets
请分享此信息
根据文档,您没有。cPacket是cMessage专门用于表示网络消息的派生类。
cPacket
cMessage
您可能必须更改代码才能使用cPackets 。
当然,如果您cPacket以这种方式为 a 分配了空间:
cMessage* message = new cPacket;
然后你可以像这样合法地把它扔掉:dynamic_cast<cPacket*>(message)
dynamic_cast<cPacket*>(message)