What this C++ compilation question tests
This is a medium-difficulty question that probes your understanding of C++ language rules around scope, linkage, and the One Definition Rule (ODR). Rather than asking you to write code, it asks you to read a snippet and reason about whether it will compile—a skill that matters when debugging build failures or reviewing code for correctness.
To answer, you'll need to think carefully about how the compiler resolves declarations and definitions across translation units, what kinds of redefinition are allowed, and where the C++ standard draws the line between a valid program and an ill-formed one. Interviewers value candidates who can spot subtle violations without running the compiler.
- Internal vs. external linkage
- Declaration vs. definition semantics
- ODR violations and how they manifest
- Storage class specifiers and scope rules