Quote:Original post by Saucetenuto
For performance reasons, the compiler requires that each field of a struct be allocated at a memory address that's a multiple of 4 (on a 32-bit architecture; different systems have different requirements here). If the whole struct is stored at address 0, then a is stored at 0, b is stored at 4, and c is stored at 8.
Actually most compilers (and MSVC for sure) require that struct members be aligned on a boundary that is a multiple of their size, unless you force a particular alignment.
So
struct A
{
int a;
char b;
char c;
int d;
};
would be 12 bytes similar to your class above, c being stored at address 5.