What this C++ object-size question tests
This is an easy C++ question about empty class optimization and memory layout. It asks you to predict the compiled size of an object, which depends on how your compiler handles empty data members and inheritance.
The question assumes familiarity with the earlier "I'm empty inside" problems in the series, building on foundational concepts around object representation. To answer correctly, you need to understand the rules governing padding, alignment, and when the compiler is permitted to optimize away seemingly-unused space. The answer is language-specific and implementation-dependent, so the question asks for the theoretical minimum across standard-compliant compilers.
- Empty class optimization (ECO)
- Object size and alignment requirements
- Compiler-dependent behaviour in C++
- Memory layout of inheritance hierarchies