What this C++ variable initialization question tests
This is an easy question about C++ initialization semantics. It probes whether you understand the difference between declaration and initialization, and how the language handles uninitialized variables in different scopes and contexts.
The question rewards precision: C++ has multiple initialization pathways (default initialization, value initialization, aggregate initialization), and the behavior depends on whether variables are local, static, or class members, and whether they have built-in or user-defined types. Getting this right requires knowing not just what the rules are, but when each rule applies.
- Local vs. static variable initialization
- Built-in type default values
- The difference between declaration and initialization
- Scope and lifetime rules