class Base
{ };
class Derived : public Base
{ };
class DerivedDerived : public Derived
{ };
If your compile implements the Empty Base Class Optimization (EBCO) and the sizeof(Base) == 1, then the sizeof(DerivedDerived) is 1.
This optimization is allowed as long as none of the same subobjects have the same address.
Reference: C++ Templates: The complete guide

No comments:
Post a Comment