What this C++ initialization question tests
This is an easy C++ language-knowledge question that probes your understanding of how variables are initialized (or left uninitialized) in different scopes and contexts. It rewards precision about the C++ standard and careful reading of code.
To answer correctly, you need to distinguish between automatic variables, static storage, stack vs. heap allocation, and the rules governing default initialization versus value initialization. Many candidates rush through these details and guess at output; the question is designed to catch that.
- Automatic vs. static storage duration
- Default initialization and zero-initialization
- Uninitialized variables and undefined behaviour