What this C++ initialization-order question tests
This is a medium-difficulty C++ question that probes your understanding of object construction and member initialization semantics. It is commonly asked in technical interviews at firms that rely on C++ for systems and trading infrastructure, where subtle initialization bugs can cause hard-to-debug failures in production.
The question requires you to trace through the order in which class members and base classes are constructed, and to reason carefully about what values are available at each stage. Many candidates underestimate how strictly C++ defines initialization order—particularly the interaction between constructor bodies, initializer lists, and member declaration order in the class definition.
- Member initializer lists vs. in-constructor assignment
- Initialization order of base classes and member variables
- Static vs. automatic storage duration
- Uninitialized reads and undefined behaviour