sizeof with virtual inheritance
Eljay Love-Jensen
eljay@adobe.com
Tue Apr 27 12:13:00 GMT 2004
Hi Adrian,
>I would like to know why the size of class objects grows when virtual
inheritance is involved.
The structure has extra bookkeeping information to keep track.
For example, if you have multiple inheritance of:
foo : bar
baz : bar
quux : foo, baz
The memory layout of quux is going to be:
bar
foo
baz
quux
If you pass a quux to something that expects a baz, that routine would expect:
bar
baz
...it wouldn't expect a "foo" stuck in the middle.
The extra "behind the scenes" bookkeeping information is used to take care
of that situation.
I do not think that it is a "onevtable" (whatever that is) related issue.
HTH,
--Eljay
More information about the Gcc-help
mailing list