0
UIM star's Avatar, Join Date: Apr 2009
Newbie Member
good article complition
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Undoubtedly Winner of Article of the month for March 2009
0
somshekhar's Avatar
Newbie Member
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)....
shabbir like this
0
kgsfun's Avatar
Newbie Member
Quote:
Originally Posted by asadullah.ansari View Post
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
0
kelvincoper's Avatar, Join Date: Nov 2010
Newbie Member
Hi Mridula,

Very Nice article. I have a query here. If I write following code in main() function
Code:
 
D1 *d = new D1;
d->function1();
will it be a late binding call?

Thanks,
0
adityapandey1207's Avatar, Join Date: Dec 2010
Newbie Member
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
0
stamhaney's Avatar, Join Date: Jan 2013
Newbie Member
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