What this C++ null-pointer question tests
This is an easy language-knowledge question that probes your understanding of null pointers and undefined behaviour in C++. Firms ask these to check that candidates grasp the difference between what code should do and what the C++ standard actually permits.
To solve it, you need to read the code carefully, identify pointer operations, and reason about what the standard guarantees—or explicitly does not guarantee—about the result. The question rewards precision: knowing that something is undefined is as important as knowing what it prints.
- Null-pointer dereference and its consequences
- Undefined behaviour vs. implementation-defined behaviour
- Output streams and their interaction with invalid operations