What this C++ const-correctness question tests
This is a conceptual C++ question that probes your understanding of const semantics and how the language interprets type qualifiers in non-obvious contexts. It's the kind of problem that separates candidates who have read the standard from those who rely on intuition alone.
The question asks you to trace through a code snippet and predict its output, which requires a precise mental model of how const applies to pointers, references, object identity, and mutable member variables. Interviewers use these questions to verify that you won't introduce subtle bugs when working with const-qualified code in a production codebase.
- Const pointers vs. pointers to const objects
- The mutable keyword and logical vs. physical constness
- Const member functions and their allowed operations
- How const casts and indirection interact