When Size Does Matter -- K-Ballo

Recently on Tales of C++:

When Size Does Matter

by K-ballo

In the C++ lands every object has mass; for any complete type T, sizeof(T) is greater than zero. This keeps array indexing and pointer arithmetics from collapsing, but it also means that empty objects occupy space. Furthermore, when an empty object is placed in a class next to a bigger member, padding may — and in all likeliness will — be added due to alignment requirements, resulting in an empty member taking more than just one byte of storage.

Certainly something has to be done about this...

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.