What this C++ pointer and reference question tests
This is a medium-difficulty question that probes your understanding of pointer semantics and reference behavior in C++. It requires you to trace through code execution carefully, paying attention to how pointers are declared, dereferenced, and reassigned.
Questions of this type appear frequently in technical interviews because they separate candidates who have internalized C++'s memory model from those who rely on surface-level intuition. You'll need to reason about what gets printed by mentally executing the code step-by-step, tracking the state of variables and the addresses they point to or refer to.
- Pointer declaration and initialization
- Dereferencing and the dereference operator
- Reference semantics and aliasing
- Stack vs. heap memory in the context of local variables