Logo

Question preview

_global_variable

What this preview is

About this preview

_global_variable is a hard quant interview question on language knowledge in Cpp.

Unlock full access to getcracked

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

What this C++ global-variable scoping question tests

This is a hard C++ language-knowledge question that probes your understanding of global scope, variable shadowing, and name resolution in the presence of multiple declarations. It rewards precise knowledge of how the C++ linker and compiler resolve symbols across translation units.

To answer correctly, you need to trace how a global variable declared in one scope interacts with identically-named entities in different scopes, and understand the rules that determine which symbol is actually used at runtime. The question tests whether you can reason about linkage, visibility, and the order in which declarations and definitions are processed—skills essential for writing correct C++ in large codebases and for diagnosing linker errors.

  • External vs. internal linkage and the static and extern keywords
  • Variable shadowing and name hiding in nested scopes
  • One Definition Rule (ODR) and symbol resolution
  • Namespace scope vs. block scope