Virtual Inheritance

C

C++

Hello,

I am unable to find any decent article on multiple inheritance.
Can someone point me to the same?

I am specifically interested in implementation details of virtual
inheritance.
(i.e. how are the objects laid out in memory, how is the virtual
pointer table made etc.

Thanks...
 
V

Victor Bazarov

I am unable to find any decent article on multiple inheritance.
Can someone point me to the same?

I am specifically interested in implementation details of virtual
inheritance.
(i.e. how are the objects laid out in memory, how is the virtual
pointer table made etc.

One of the best "references" on the subject is Stan Lippman's "Inside
the C++ Object Model". The memory layout and vptr are implementation
details and cannot really be generalized. Consider asking in the
newsgroup for your implementation (compiler).

V
 
V

Victor Bazarov

You mean there are significantly different implementations of vtables
and virtual inheritance in different compilers/systems?

No, I did not mean that. I meant (in case it's not obvious), that those
are implementation details and that they aren't prescribed (specified)
by the Standard.
I would be interested in seeing a couple of examples of such significantly
different implementations.

When I have time to waste, so would I.

V
 
J

Juha Nieminen

Victor Bazarov said:
No, I did not mean that. I meant (in case it's not obvious), that those
are implementation details and that they aren't prescribed (specified)
by the Standard.

I understood that the original poster was interested in those
implementation details, not on what the Standard says about it.
 
V

Victor Bazarov

I understood that the original poster was interested in those
implementation details, not on what the Standard says about it.

Yes, and?

Juha, if you would like to provide another answer to the OP, by all
means do so, nobody is going to blame you for that.

V
 
J

James Kanze

You mean there are significantly different implementations of
vtables and virtual inheritance in different
compilers/systems?

It's been quite some time since I looked at them, but at least
in the past there were (where virtual inheritance was involved).
I would be interested in seeing a couple of examples of such
significantly different implementations.

Not particularly current, but CFront and HP's aCC used very
different techniques---g++ was also quite different from CFront.
(I'm sorry I don't remember more about the actual layouts---all
I do remember was that for a small set of test classes, along
the lines of:
class VB {};
class R : public virtual VB {};
class L : public virtual VB {};
class D : public R, public L {};
, but with an int in each class (and a virtual destructor,
etc.), sizeof(D) varied by a factor: CFront was twice the size
of g++ (and IIRC, aCC was very close to g++).
 

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,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top