What are storage classes?
Storage Classes are used to describe the features of a variable/function. These features
basically include the scope, visibility and life-time which help us to trace the existence of a
particular variable during the runtime of a program.
For example:
Storageclass datatype variablename;
A storage class defines the scope (visibility) and life-time of variables and/or functions within a
C++ Program. These specifiers precede the type that they modify. There are following storage
classes, which can be used in a C++ Program.
auto
register
static
extern
mutable
Auto Class:
The auto storage class is the default storage class for all local variables.
For example:
{
int day;
auto int month;
}
The example above defines two variables with the same storage class, auto can only be used
within functions, i.e., local variables.
The Register storage Class:
The register storage class is used to define local variables that should be stored in a register
instead of RAM. This means that the variable has a maximum size equal to the register size
(usually one word) and can't have the unary '&' operator applied to it (as it does not have a
memory location).
For example:
{
register int miles;
Storage Classes are used to describe the features of a variable/function. These features
basically include the scope, visibility and life-time which help us to trace the existence of a
particular variable during the runtime of a program.
For example:
Storageclass datatype variablename;
A storage class defines the scope (visibility) and life-time of variables and/or functions within a
C++ Program. These specifiers precede the type that they modify. There are following storage
classes, which can be used in a C++ Program.
auto
register
static
extern
mutable
Auto Class:
The auto storage class is the default storage class for all local variables.
For example:
{
int day;
auto int month;
}
The example above defines two variables with the same storage class, auto can only be used
within functions, i.e., local variables.
The Register storage Class:
The register storage class is used to define local variables that should be stored in a register
instead of RAM. This means that the variable has a maximum size equal to the register size
(usually one word) and can't have the unary '&' operator applied to it (as it does not have a
memory location).
For example:
{
register int miles;