Understanding object creation and initialization in C++
This is an easy C++ question that tests whether you can read and predict the behaviour of code involving object construction and initialization. It is the kind of fundamental knowledge that interviewers verify early in a coding round, often as a warm-up before moving to more complex problems.
The question requires you to trace through the lifecycle of objects as they are declared and constructed, paying careful attention to how different initialization syntax behaves and what side effects—if any—occur during creation. This skill is essential for writing predictable code and debugging subtle issues in real systems.
- Constructor invocation and order of execution
- Different initialization syntaxes and their semantics
- When code runs and what gets printed or executed
- Distinguishing between declaration, definition, and instantiation