[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [LC++]virtual functions



On 29/10/2004, at 8:33 PM, Adriano dos Santos Fernandes wrote:

Paul Gearon wrote:

If not for the virtual table then a pointer of type base* would always find the base::print() method, even if the object is of type "derived". Calling a method on an object without a virtual table just goes to some fixed offset from the start of the object to find the method.

Wrong. The method is called as a normal function (resolved by the linker).
A class that don't have virtual functions is as a C struct, it don't have "hide" variables.

Sorry. You're quite correct here. If things were done that way then you'd end up with the same code being repeated for every object of the same type.


Not sure what I was thinking when I wrote that  :-}

Regards,
Paul Gearon

Software Engineer
Tucana Technologies
http://www.tucanatech.com

Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum
immane mittam.
(Translation from latin: "I have a catapult. Give me all the money,
or I will fling an enormous rock at your head.")