Thursday 10 November 2011

Storage Class Specifiers in C++


Storage specifiers specify the scope linkage and lifetime of a variable.
The default storage specifier for all function parameters and variables is auto.


auto -  specifies an automatic variable. The storage scope is limited to the scope of the inner braces the variable is declared.


register - this indicates the compiler to store the variable in the CPU registers to allow fast access. However the modern compilers are smart enough= to figure which variables have to be stored in the registers.


mutable - denotes that the member can be modified even if the containing object is a const.


static - denotes a variable with static linkage, function parameters should never be made static.


extern - Denotes the variable is declared in another file.

No comments:

Post a Comment