MS VC++ 6.0 object memory layout

A

ankit.ankit

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

msalters

(e-mail address removed) 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top