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 允许安全的向下转换。
omnet源码解释2
最新推荐文章于 2021-03-13 08:54:10 发布