C++: What is the size of an object of an empty class?

Quoting Bjarne Stroustrup’s C++ Style and Technique FAQ, the reason the size is non-zero is “To ensure that the addresses of two different objects will be different.” And the size can be 1 because alignment doesn’t matter here, as there is nothing to actually look at.

Leave a Comment