Explain the different storage classes in C++ (auto, register, static, extern) and where they are stored in the memory map.

Last updated 21 June 2026

  • Storage classes set lifetime and linkage: auto meant stack locals (now repurposed for type deduction), and register was a CPU-register hint (now deprecated/removed).

  • static gives whole-program lifetime in the data/BSS segment, internal linkage at file scope, and value persistence for locals.

  • extern declares an externally linked object defined in another translation unit, stored in that unit's data segment.

  • https://www.interviewbit.com/c-interview-questions/
  • https://www.interviewbit.com/c-interview-questions-2026/
All C++ interview questions