MS VC++ 6.0 object memory layout

Discussion in 'C++' started by ankit.ankit@gmail.com, Jun 28, 2005.

  1. Guest

    Referring to the following links.
    1.
    http://groups-beta.google.com/group...yout virtual multiple&rnum=6#c66539a90194bfbc
    2.
    http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvc/html/jangrayhood.asp

    Q1. Can somebody tell what does the phrase
    "non-virtually-inherited parts" as referred in John Gray's post at the
    end of the page referred by 1st link

    Also, for class M: public X, public Y
    where X and Y both have virtual functions (and thus have vfptrs),
    class M will contain two vfptrs (one each for embedded instances of X
    and Y).

    Q2. Each class has only one vftable asociated with it. So, do the two
    vfptrs (as above) point to the same vtable? The rule of one vtable is
    violated when doing virtual inheritance of a base class with virtual
    functions and derived class adding new virtual functions.

    Q3. Also, the vtable for M will have two entries for the same func().
    When doing a lookup for func(), which of the two entries is refrred to.
     
    , Jun 28, 2005
    #1
    1. Advertising

  2. msalters Guest

    schreef:

    > Also, for class M: public X, public Y
    > where X and Y both have virtual functions (and thus have vfptrs),
    > class M will contain two vfptrs (one each for embedded instances of X
    > and Y).


    Probably three, as M might add virtual functions of its own.

    > Q2. Each class has only one vftable asociated with it. So, do the two
    > vfptrs (as above) point to the same vtable? The rule of one vtable is
    > violated when doing virtual inheritance of a base class with virtual
    > functions and derived class adding new virtual functions.


    What rule? It probably wouldn't work, either. X and Y are unrelated,
    and have different virtual functions. I.e. the first virtual function
    will differ, and __vtable[0] will then be different.

    > Q3. Also, the vtable for M will have two entries for the same func().
    > When doing a lookup for func(), which of the two entries is refrred to.


    Name lookup doesn't happen at runtime in vtables, but at compile time.

    HTH,
    Mchiel Salters
     
    msalters, Jun 28, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Spiewak
    Replies:
    3
    Views:
    3,167
    Rick Spiewak
    Aug 26, 2003
  2. RobertH
    Replies:
    1
    Views:
    732
    Steve C. Orr [MVP, MCSD]
    Nov 4, 2003
  3. NWx
    Replies:
    4
    Views:
    2,968
    Kevin Spencer
    Feb 19, 2004
  4. Eric
    Replies:
    4
    Views:
    741
    clintonG
    Dec 24, 2004
  5. Replies:
    1
    Views:
    598
    John Timney \(MVP\)
    Jun 19, 2006
Loading...

Share This Page