omnet源码解释2

 CPOLYMORPHIC.H
       cPolymorphic是一个轻量级的共有基类,是cObject的直接基类,只包含了一些成员函数,不包含数据成员。
         It is recommended to use cPolymorphic as a base class for any class that has at least one virtual member function. This makes the class more  interoperable with /opp, and causes no extra overhead at all. sizeof(cPolymorphic) should yield 4 on a 32-bit architecture (4-byte * <i>vptr</i>), and using cPolymorphic as a base class doesn't add anything to the size because a class with a virtual function already has a vptr.
        推荐cPolymorphic作为任何类的基类,并且至少包含一个虚拟成员函数。这将使类和/opp能共同使用,并且不会使用额外的开销。 sizeof(cPolymorphic) 在32位的机器上的结果应该是4。使用cPolymorphic 作为基类不会增加任何大小,因为一个含有虚函数的类已经有一个vptr。
        cPolymorphic allows the object to be displayed in graphical user interface (Tkenv) via the className(), info() and detailedInfo() methods which you may choose to redefine in your own subclasses.
        通过调用className(),info() 和 detailedInfo() 函数, cPolymorphic容许对象在图形接口中显示出来(Tkenv)
你可以有选择性的在你的子类中重新定义它们。
        Using cPolymorphic also strengthens type safety. cPolymorphic *pointers should replace <tt>void *</tt> in most places where you need  pointers to "any data structure". Using cPolymorphic will allow safe downcasts using <tt>dynamic_cast</tt> and also /opp's   <tt>check_and_cast</tt>.
        使用cPolymorphic也是类型安全的。在大多数情况下, cPolymorphic *可以被void*指针代替,你可以用它来通过调用dynamic_cast或check_and_cast可以把指向任何 cPolymorphic 允许安全的向下转换。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值