Storage class specifiers are keywords that can be used in declarations. They do not affect the type of the declaration, but typically modify the way in which the entity is stored.
There are six storage class specifiers, although not all in the same version of the language: auto
(until C++11), register
(until C++17), static
, thread_local
(since C++11), extern
, and mutable
.
According to the standard,
At most one storage-class-specifier shall appear in a given decl-specifier-seq, except that
thread_local
may appear withstatic
orextern
.
A declaration may contain no storage class specifier. In that case, the language specifies a default behaviour. For example, by default, a variable declared at block scope implicitly has automatic storage duration.