Why is the size of an empty class in C++ not zero? [duplicate]

The standard does not allow objects (and classes thereof) of size 0, since that would make it possible for two distinct objects to have the same memory address. That’s why even empty classes must have a size of (at least) 1.

Leave a Comment