Logo

Question preview

Who comes first?

What this preview is

About this preview

Who comes first? is a medium quant interview question on language knowledge in Cpp, asked at Quant.

Unlock full access to getcracked

Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.

Understanding C++ declaration and initialization order

This is a medium-difficulty C++ question that tests your grasp of declaration sequencing, static initialization, and the order in which constructors and destructors execute. Quant shops ask questions like this to verify that candidates understand the subtle timing guarantees (and pitfalls) built into the C++ standard, since latency-critical systems depend on predictable object lifecycles.

To answer correctly, you need to trace through the code mentally: identify which objects are declared at what scope, understand which ones are constructed first, and reason about what gets printed and when. Pay close attention to static vs. automatic storage duration, and whether any initialization order dependencies exist that could surprise you. The answer hinges on details that don't show up in simpler languages.

  • Static initialization order and the static initialization order fiasco
  • Scope and storage class (automatic, static, global)
  • Constructor and destructor execution order