Understanding storage duration categories in C++
This is an easy foundational question on C++ language semantics. It tests whether you can recall and distinguish between the four distinct categories that govern how long an object persists in memory and which scope can access it.
Storage duration is a core concept that underpins memory management, variable lifetime, and scope rules in C++. Interviewers ask this to establish that you have a solid grasp of the language fundamentals before moving to more complex design or performance topics. The question rewards clear categorization and the ability to explain what differentiates each type in terms of allocation, initialization, and cleanup.
- Relationship between storage duration and variable scope
- Automatic cleanup and explicit deallocation
- Static initialization and lifetime across program execution
- Dynamic allocation and manual memory management