In Chapter 6, we described two types of variables: automatic and static. Recall that if a local variable of a function is static, it exists between function calls. Similar to static variables, a class can have static members, functions, or variables. C++, static members of a class refer to variables and methods that belong to the class itself rather than to individual instances (objects) of the class. A static member is shared among all instances of a class and is only initialized once when the class is loaded. To declare a static member, you use the static
keyword in the member's declaration.
If a function of a class is static, in the class definition, it is declared using the keyword static in its heading.
If a member variable of a class is static, it is declared using the keyword static,
A public static member, function, or variable of a class can be accessed using the class name and the scope resolution operator.
...
.
Here's an example of a static class member:
...