What this C++ language-knowledge question tests
This is a medium-difficulty question that probes your understanding of object lifetime, scope, and how C++ handles temporary objects and references. It rewards careful reading of initialization syntax and memory semantics rather than guesswork.
To answer correctly, you need to trace the execution path step by step: identify which objects are created, where they live in memory, and what happens when control flow exits their scope. Pay close attention to how references bind to temporaries, how constructors and destructors fire, and whether the code even compiles as written. These are exactly the kinds of subtle semantic questions that trip up candidates who rely on intuition rather than the language rules.
- Temporary object lifetime and const references
- Reference binding rules
- Constructor and destructor order
- Scope and automatic storage duration