14.6 The Meaning of static

I l @ ve RuBoard

The keyword static has many different meanings in C++. Table 14-1 is a complete list of the various ways static can be used.

Table 14-1. The meanings of static

Usage

Meaning

Variable outside the body of any function

The scope of the variable is limited to the file in which it is declared.

Variable declaration inside a function

The variable is permanent. It is initialized once, and only one copy is created even if the function is called recursively.

Function declaration

The scope of the function is limited to the file in which it is declared.

Member variable

One copy of the variable is created per class (not one per object).

Member function

Function can only access static members of the class.

I l @ ve RuBoard


Practical C++ Programming
Practical C Programming, 3rd Edition
ISBN: 1565923065
EAN: 2147483647
Year: 2003
Pages: 364

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net