What this C++ reference-binding interview question tests
This is a medium-difficulty C++ language-knowledge question that probes your understanding of non-const reference binding rules and how the compiler enforces them. It's a common screen at firms that rely on low-latency C++ systems, where subtle misunderstandings about reference semantics can introduce silent bugs.
To answer correctly, you need to recall which expressions can safely bind to a non-const reference parameter, why the language restricts this binding, and what the compiler will or won't allow. The question tests whether you understand the distinction between lvalues and temporary objects, and how modern C++ applies those rules in practice.
- Lvalue vs. rvalue and their reference bindings
- Temporary object lifetime and non-const reference semantics
- Compiler diagnostic behaviour under standard rules