Click to See Complete Forum and Search --> : When is the Virtual table for any class created?


thomas_mathews
February 9th, 2004, 11:42 PM
Hello,
can any one please clarify following doubts.
If any Derived class overrides the virtual function from Base classs, then for the Derived class the Virtual Table contain the address of Derived function (this can be known in compile time) . And each Base and Derived Class has separate Virtual Table.

When is the Virtual table for any class created?Is it in compile time or in Runtime? and explaination?

Regards,
Thomas

Jaistmathew
February 10th, 2004, 01:49 AM
:)
Hi...
There will be separate VTABLE of each classes.
Layout of VTABLE is fixed at compile time..index… and name..
Then get the address at runtime….
All VTABLEs will create in the data segment at startup…
On object creation it will get the address of VTABLE belongs to it.

That means complier put some more instruction for all this….. we don’t want to take care…

Some difference may occure….. because some are complier specific..

:thumb:

Jais T Mathew

thomas_mathews
February 10th, 2004, 02:31 AM
Hello,
Thanks for the information .if u have link for it please send me. mail me.

Regards,
Thomas:wave:

Charleston
February 10th, 2004, 02:34 AM
Originally posted by Jaistmathew
:)
Hi...
There will be separate VTABLE of each classes.
Layout of VTABLE is fixed at compile time..index… and name..
Then get the address at runtime….
All VTABLEs will create in the data segment at startup…
On object creation it will get the address of VTABLE belongs to it.

That means complier put some more instruction for all this….. we don’t want to take care…

Some difference may occure….. because some are complier specific..

:thumb:

Jais T Mathew
You are right.
I have learnt a lot from your post. True !

BTW, I like your signature, I have my own faith and always hopefully believe in my future, nothing can break Fiona into pieces, that is always the truth, forever...Thanks a lot for your words, they invoke my eagerness for learning new things... I am in a different class, yes. :)

Charleston
February 10th, 2004, 02:37 AM
Originally posted by thomas_mathews
Hello,
Thanks for the information .if u have link for it please send me. mail me.

Regards,
Thomas:wave:
If you want to know about Vtable, there is a link in this forum, you can do a search, but that pdf file content is written in German, i think you will need some translation at least..

HTH :)

thomas_mathews
February 10th, 2004, 02:58 AM
Hello,
so the layout of Virtual Table is fixed at compile time. But Actually Virtual Table is created at runtime?
what about the entries in the virtual table , i mean pointer to function , i think that information we can get in comiple time. when this entries is filled up.if anyone have any link for these topics plz post the reply.


Regards,
Thomas

Paul McKenzie
February 10th, 2004, 07:49 AM
Since this is the non-Visual C++ forum, may I point out that it is not necessary for a compiler to even have a virtual table.

There is no specification as to how virtual functions are performed by any compiler. So the original question should state the brand of compiler and version.

Regards,

Paul McKenzie

Jaistmathew
February 11th, 2004, 12:03 AM
Originally posted by thomas_mathews
Hello,
so the layout of Virtual Table is fixed at compile time. But Actually Virtual Table is created at runtime?
what about the entries in the virtual table , i mean pointer to function , i think that information we can get in comiple time. when this entries is filled up.if anyone have any link for these topics plz post the reply.


Regards,
Thomas

:) Thomas...

The layout is fixed at compile time.... but fixing the layout in to the memory is happening at runtime... and memory address of functions is getting at runtime....
i Think u got the idea.......

compiler will set the instruction for all this ...

All the best...

:thumb:
Jais T Mathew

thomas_mathews
February 11th, 2004, 03:06 AM
hello Mathew,
yaa, i got . Thanks for the information.
Regards,
Thomas:)