omnet源碼解釋2

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.