How is an empty class and empty structure compiled?

Does the C ++ standard match the compilation layout of the class and structure? How are they compiled differently, especially if they are empty?

+7
source share
1 answer

He does this in a way, he says that he should allocate space for him, if not certain cases, when he is used as a base class (known as "Optimizing an empty base class"). This ensures that different objects have different addresses.

They are compiled in the same way that struct and class are the same thing, with the exception of the default access specifier. C ++ 11 introduces the concept of standard layout classes / structures and ensures that the memory layout for empty classes is the same.

+13
source

All Articles