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 允許安全的向下轉換。