What this C++ constant-handling interview question tests
This is a medium-difficulty C++ language-knowledge question of the kind Google and other tech firms use to assess whether candidates understand how the compiler treats constants, scope rules, and variable shadowing. It rewards careful reading of code over rote memorization of arcane syntax.
To work through problems like this, candidates must trace the visibility and lifetime of identifiers across nested scopes, recognize when a declaration shadows or redeclares a prior one, and predict what the preprocessor and compiler will output. The question probes both your mental model of C++ scoping and your ability to spot subtle interactions between const qualifiers, linkage, and name resolution.
- Internal vs. external linkage and the static keyword
- Scope shadowing and name hiding
- Const correctness and compile-time vs. runtime binding
- Preprocessor vs. compiler semantics