Resolving a Shared Variable
What this preview is
Resolving a Shared Variable is a easy quant interview question on language knowledge in Cpp.
- Difficulty
- Easy
- Topic
- Language Knowledge
- Discipline
- Quant development
- Language
- Cpp
- Companies
- 0
Understanding C++ static storage and symbol resolution
This is an easy C++ language-knowledge question that tests your grasp of how the compiler and linker handle variable scope, linkage, and storage duration across translation units. It's a foundational concept that appears regularly in technical interviews, especially at firms where C++ is the primary implementation language.
The question requires you to trace through how declarations, definitions, and linkage specifiers (like static or extern) interact when two source files are compiled separately and then linked together. You need to reason about which symbol the linker resolves, whether a variable has internal or external linkage, and what the observable behaviour is at runtime.
- Internal vs. external linkage
- The
statickeyword and file scope - Translation unit boundaries and the one-definition rule (ODR)
- Linker symbol resolution
Related practice
Unlock full access to getcracked
Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.