What this C++ array-semantics interview question tests
This is a hard language-knowledge question that probes your understanding of how arrays, pointers, and memory layout work in C++. It requires you to reason precisely about the compiled behaviour of code rather than guess at high-level semantics — a skill that separates strong C++ candidates from casual ones.
To solve this, you need to understand pointer arithmetic, array decay, the relationship between arrays and addresses in 64-bit memory, and how the compiler lays out data. The question rewards candidates who can mentally execute the code step-by-step and predict the actual output, not just the intended logic.
- Pointer arithmetic and scaling by element size
- Array-to-pointer decay and subscript semantics
- Memory layout and address arithmetic in 64-bit systems
- Distinguishing between what code appears to do and what it actually does