storage durations
From cppreference.com
Storage duration
All variables in a program have one of the following storage durations:
- automatic storage duration. The variable is allocated at the beginning of the enclosing code block and deallocated on end. All non-global variables have this storage duration, except those declared
static
,extern
orthread_local
.
- automatic storage duration. The variable is allocated at the beginning of the enclosing code block and deallocated on end. All non-global variables have this storage duration, except those declared
- static storage duration. The variable is allocated when the program begins and deallocated when the program ends. Only one instance of the variable exists. All global variables have this storage duration, plus those declared with
static
orextern
.
- static storage duration. The variable is allocated when the program begins and deallocated when the program ends. Only one instance of the variable exists. All global variables have this storage duration, plus those declared with
|
(since C++11) |
- dynamic storage duration. The variable is allocated and deallocated per request by using dynamic memory allocation functions.