size of empty class

why is the size of empty class non zero in c++?
Because if it was zero bytes then there wouldn't be a class. You can still reference a class even if its empty, and its to ensure two different objects from the same empty class have different addresses. So at least 1 byte is allocated for an empty class.

http://www.geeksforgeeks.org/why-is-the-size-of-an-empty-class-not-zero-in-c/
Last edited on
Topic archived. No new replies allowed.