Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/articles/cpp-tutorials/)
-   -   How Virtual Table and _vptr works (http://www.go4expert.com/articles/virtual-table-vptr-t16544/)

UIM star 25Apr2009 00:35

Re: How Virtual Table and _vptr works
good article complition

shabbir 29Apr2009 17:54

Re: How Virtual Table and _vptr works
Undoubtedly Winner of Article of the month for March 2009

somshekhar 18Aug2010 10:46

Re: How Virtual Table and _vptr works
Hi Mridula,
Its a nice article but i want to add on to that ...

When we create the object like

Base* pBase = new Derived;
Now as the pointer is of the base class but the object is created of the derived type then when we call a function

pBase->Function1(); The first and the foremost thing happens is that first four bytes of object is extracted which stores the virtual table address and is set to the vptr and since the object is of the type derived it goes to the derived class v-table and calls the corrosponding function, and if a particular function is not overridden in the derived class then it keeps the reference from which class it has been derived..(most derived class not necessarily the base class, could be the class just above the derived class)....

kgsfun 17Oct2010 03:40

Re: How Virtual Table and _vptr works

Originally Posted by asadullah.ansari (Post 44443)
Nice article....

Excellent article, which makes me to understand about virtual functions and pointers very well. It was always a confusion, now I"m confident to answer the questions shooted by interviewers :)

thanks a lot

kelvincoper 24Nov2010 12:58

Re: How Virtual Table and _vptr works
Hi Mridula,

Very Nice article. I have a query here. If I write following code in main() function

D1 *d = new D1;

will it be a late binding call?


adityapandey1207 15Jan2011 22:52

Re: How Virtual Table and _vptr works
Really nice article...Please can you post one more article on how to VPTR, Vtable handles in case of Virtual base class. and
Plz can u explain what's normalized pointers and difference btwn near,far and huge pointers

stamhaney 14Jan2013 22:48

Re: How Virtual Table and _vptr works
Hi Mridula,

One question. In the pictorial representation of the vtable, you have shown that D1 and D2 have virtual destructors, whereas both D1 and D2 do not have virtual destructors., the desturctor of only base is virtual

All times are GMT +5.5. The time now is 21:01.