What this C++ const-qualification question tests
This is an easy C++ language-knowledge question that probes your understanding of const semantics and how the compiler enforces constness in different contexts. It's the kind of detail-oriented question quant trading firms use to filter for candidates who can write robust, predictable C++ code without subtle runtime surprises.
The question asks you to trace through a code snippet and reason about what gets printed—or whether compilation even succeeds. Success requires understanding const qualification rules, method binding, and where the compiler will raise an error versus permit the code to run. Getting this right demonstrates that you've internalized how const prevents accidental mutations in performance-critical codebases.
- Const member functions and const correctness
- Mutable vs. const object behaviour
- Compiler enforcement of const rules
- Return-type const-ness and assignability