Click here to Skip to main content
15,903,385 members

Comments by Member 13913102 (Top 4 by date)

Member 13913102 23-Nov-18 4:10am View    
yes I agree with you. This means first compiler should agree it, vtable comes in picture at runtime.
Thx for your valuable comments and answers.
Member 13913102 23-Nov-18 4:01am View    
vtable explanation which I learnt is here:
http://www.learncpp.com/cpp-tutorial/125-the-virtual-table/
Member 13913102 23-Nov-18 3:59am View    
yes I missed on polymorphism, but see this link, it says __vptr will point to __vtable of derived class, and this __vtable will have pointer to func_2, then it must be accessed.
http://www.learncpp.com/cpp-tutorial/125-the-virtual-table/
Member 13913102 23-Nov-18 3:00am View    
thx for your detailed explanation, I will go thru your answer again, I still have few doubts.
If in base class I rename func_1 as func_2, then this will work fine and derived class function will be called, as concepts of __vtable and __vptr make it happen. __vptr will have address of __vtable of derived class.
But before renaming func_1 to func_2(in original code), why __vptr was not able to find virtual func_2

vtable explanation which I learnt is here:
http://www.learncpp.com/cpp-tutorial/125-the-virtual-table/