Understanding pointer semantics and memory in C++
This is a medium-difficulty C++ question that tests whether you can trace pointer operations and predict program output accurately. It's the kind of question quant dev interviews use to confirm you understand how pointers, dereferencing, and memory addresses work in practice—not just in theory.
To answer correctly, you need to carefully follow what each pointer holds (an address or a value), what operations are performed on them, and what the final state of memory looks like. The question rewards precise mental execution: one misread of a dereference operator or an off-by-one assumption will lead you astray. Interviewers often use this format to separate candidates who have internalized pointer semantics from those who are still guessing.
- Pointer declaration and initialization
- The
& (address-of) and * (dereference) operators - Pointer reassignment vs. value reassignment
- Predicting console output from code inspection