The static storage class specifier
Objects declared with the static storage class
specifier have static storage duration, which means that memory
for these objects is allocated when the program begins running and
is freed when the program terminates. Static storage duration for
a variable is different from file or global scope: a variable can
have static duration but local scope.
The keyword static is the major mechanism
in C to enforce information hiding.
C++
enforces information hiding through the namespace language feature
and the access control of classes. The use of the keyword static to
limit the scope of external variables is deprecated for declaring
objects in namespace scope.
The
static storage class specifier can be applied
to the following declarations: - Data objects
Class members- Anonymous unions
You cannot use the
static storage class specifier
with the following: - Type declarations
- Function parameters
Related information