看板 EE_DSnP 關於我們 聯絡資訊
※ 引述《popo4231 (小泰)》之銘言: : 如題... virtual function is used by derived class to override the definition of the function in the parent class. However, when an object is being created, e.g. Parent *p = new Child; // 看不懂? 下一章會教到... The parent constructor will be called first anyway, and then the derived class constructor (Child) will be called. Besides, the "virtual table pointer" of the derived class object was assigned when the derived class constructor is called, so there is no need to declare the parent class constructor since there is NO WAY for the child class object to know which virtual function to call (no virtual table pointer...). -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.121.134.219