Two-Phase Lifecycle
What this preview is
Two-Phase Lifecycle is a medium quant interview question on language knowledge in Cpp.
- Difficulty
- Medium
- Topic
- Language Knowledge
- Discipline
- Quant development
- Language
- Cpp
- Companies
- 1
Understanding object lifecycle and initialization in C++
This is a medium-difficulty C++ code-reading question that tests your grasp of object construction and destruction across different scopes and storage durations. It's the kind of problem that trips up candidates who haven't internalized when constructors and destructors run, or who conflate different initialization semantics.
To solve it, you'll need to trace the execution flow carefully, noting which objects are created in which scope, how their lifetimes overlap, and what side effects (printing, state changes) occur during each phase. Pay close attention to object order of construction and destruction, temporary lifetimes, and any explicit scope boundaries in the code.
- Constructor and destructor invocation order
- Scope and automatic storage duration
- Temporary objects and their lifetimes
- Stack-based object management
Related practice
Unlock full access to getcracked
Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.