Re: sizeof with virtual inheritance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux