A storage class specifier is used to refine the declaration of a variable, a function, and parameters. The storage class specifier used within the declaration determines whether:
For a variable, its default storage duration, scope, and linkage depend on where it is declared: whether inside or outside a block statement or the body of a function. When these defaults are not satisfactory, you can specify an explicit storage class: auto, static, extern, or register. In C++, you have the additional option of being able to specify the storage class mutable for a class data member to make it modifiable, even though the member is part of an object that has been declared const.
For a function, the storage class specifier determines the linkage of the function. The only options are extern and static. A function that is declared with the extern storage class specifier has external linkage, which means that it can be called from other translation units. A function declared with the static storage class specifier has internal linkage, which means that it may be called only within the translation unit in which it is defined. The default for a function is external linkage.
The only storage class that can be specified for a function parameter is
register. The reason is that function parameters have the same
properties as auto variables: automatic storage duration,
block scope, and no linkage.
Declarations with the auto or register storage class specifier result in automatic storage. Those with the static storage class specifier result in static storage.
Most local declarations that do not include the extern storage class specifier allocate storage; however, function declarations and type declarations do not allocate storage.
The only storage class specifiers allowed in a namespace or global scope declaration are static and extern. In C++, the use of static for a specifying internal linkage is deprecated. Use the unnamed namespace instead.
The storage class specifiers in C and C++ are:
Related References