In the description
A class that contains a virtual pointer, but no other data except (possibly) virtual bases. In particular ...
What does virtual bases
mean here? a dynamic base classs? or classes virtually inherited by the most derived class? I think it's the second explaination, but using gcc to dump-class-hierarchy will show that normally inherit from dynamic classes can make the most derived class nearly empty
too, is there something wrong?
below code will show that a class NearlyEmpty2 which not virtually inherited from two dynamic classes is a nearly empty class.
cpp code
struct Empty {};
struct NearlyEmpty { virtual void d() {}};
struct NearlyEmpty2: public NearlyEmpty, public Empty {};
output of g++ -fdump-class-hierarchy NearlyEmpty.cpp
Class NearlyEmpty2
size=8 align=8
base size=8 base align=8
NearlyEmpty2 (0x0x7fc7eaeed460) 0 **nearly-empty**
vptr=((& NearlyEmpty2::_ZTV12NearlyEmpty2) + 16u)
NearlyEmpty (0x0x7fc7eb044720) 0 nearly-empty
primary-for NearlyEmpty2 (0x0x7fc7eaeed460)
Empty (0x0x7fc7eb044780) 0 empty