[LC++]virtual functions
Torsten Rennett
Torsten at Rennett.de
Thu Oct 28 17:37:01 UTC 2004
On Donnerstag, 28. Oktober 2004 10:17, choube mehul wrote:
> when is the virtual table created?
When the object is created.
> will a virtual table created in the following
> scenario?
For objects of class base a virtual table will be created, but not for
objects of class derived.
> if created why?
Because class base has a virtual method print().
> if not created why?
Because class derived has no virtual methods.
(Note: class derived is not derived from any class.)
> class base
> {
> virtual void print (void)
> {
> cout << "base"<<endl;
> }
> };
>
> class derived
> {
> void print (void)
> {
> cout << "derived" << endl;
> }
> };
>
> int main (int argc, char argv)
> {
> derived d;
>
> return 0;
> }
--
Ingenieurbuero RENNETT -- innovative Software-Entwicklung --
Torsten Rennett http://www.RENNETT.de
Ludwig-Thoma-Weg 14 E-Mail: Torsten at Rennett.de
D-85551 Heimstetten Telefon: +49 89 904 805 38
More information about the tuxCPProgramming
mailing list