Define storage classes in C++.Storage class defined for a variable determines the accessibility and longevity of the variable. The accessibility of the variable relates to the portion of the program that has access to the variable. The longevity of the variable refers to the length of time the variable exists within the program.
Auto : Automatic variable, also called as local variable and it has scope only within the function block where it is defined.
External : External variable are defined outside any function and memory is set aside for this type of variable once it is declared and remained until the end of the program. These variables are also called global variables.
Static : The static automatic variables, as with local variables, are accessible only within the function in which it is defined. Static automatic variables exist until the program ends in the same manner as external variables. In order to maintain value between function calls, the static variable takes its presence.
|