class Base { }; class Derived : public Base { };
If your compile implements the Empty Base Class Optimization (EBCO) and the sizeof(Base) == 1, then the sizeof(Derived) is 1.
Since there is only one subobject, the object and the subobject can share the same address.
Reference: C++ Templates: The complete guide
No comments:
Post a Comment