User talk:Tatavaraprasad

Storage Class Specifiers

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:

The object has internal, external, or no linkage The object is to be stored in memory or in a register, if available The object receives the default initial value 0 or an indeterminate default initial value The object can be referenced throughout a program or only within the function, block, or source file where the variable is defined The storage duration for the object is static (storage is maintained throughout program run time) or automatic (storage is maintained only during the execution of the block where the object is defined) 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:

auto extern mutable register static typedef typedef is categorized as a storage class specifier because of similarities in syntax rather than functionality and because a typedef declaration does not allocate storage. Related References

auto Storage Class Specifier extern Storage Class Specifier mutable Storage Class Specifier register Storage Class Specifier static Storage Class Specifier typedef Program Linkage