Re: virtual and class size
On Aug 24, 2:53 am, Robert Wessel <robertwess...@yahoo.com> wrote:
On Tue, 23 Aug 2011 17:29:32 -0700 (PDT), Christopher
[Just nits...]
The vtable looks like what the compiler wants it to look like. A
common implementation is that the vtable is an array of pointers to
all of the virtual functions in a class,
Plus a pointer to the rest of the RTTI information. And
depending on the implementation, the pointer to the virtual
function might also contain a value used to fix up the this
pointer.
and one exists for the base
class and for every derived class.
Conceptually, there should be a vtable for the most derived
class, and for each of the base classes in the most derived
class, e.g.:
struct B1 { virtual ~B1(); };
struct B2 : B1 {};
struct B3 { virtual ~B3(); };
struct D : B2, B1 {};
Conceptually, there is a vtable for B1 in D, B2 in D, B3 in D
and D. The vtables B1 in D, B2 in D and B3 in D will be
different than those for B1, B2 and B3 as most derived classes.
Practically, the compiler will be able to merge some of these
(B1, B2 and D in most implementations.)
Virtual inheritance, of course, only makes the issue more
complex.
--
James Kanze