CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2002
    Location
    India
    Posts
    138

    Angry When is the Virtual table for any class created?

    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

  2. #2
    Join Date
    Feb 2004
    Location
    Bangalore..
    Posts
    8

    Lightbulb


    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..



    Jais T Mathew
    Believe in God..
    if u have Faith, Hope and Love... u will get everything

  3. #3
    Join Date
    Oct 2002
    Location
    India
    Posts
    138
    Hello,
    Thanks for the information .if u have link for it please send me. mail me.

    Regards,
    Thomas

  4. #4
    Join Date
    Feb 2004
    Posts
    138
    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..



    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.

  5. #5
    Join Date
    Feb 2004
    Posts
    138
    Originally posted by thomas_mathews
    Hello,
    Thanks for the information .if u have link for it please send me. mail me.

    Regards,
    Thomas
    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

  6. #6
    Join Date
    Oct 2002
    Location
    India
    Posts
    138
    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

  7. #7
    Join Date
    Apr 1999
    Posts
    27,449
    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

  8. #8
    Join Date
    Feb 2004
    Location
    Bangalore..
    Posts
    8
    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...


    Jais T Mathew
    Believe in God..
    if u have Faith, Hope and Love... u will get everything

  9. #9
    Join Date
    Oct 2002
    Location
    India
    Posts
    138
    hello Mathew,
    yaa, i got . Thanks for the information.
    Regards,
    Thomas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured