posted October 31, 1999 01:12 PM
Hifirst there's three types of static variables.
Global static variables, local static variables and member static variables.
Global static variables are variables that are accessible at file scope only. So if you use many files (.cpp for instance), only the one that have the definition will be able to use it even if it is global to the program.
local static variables are variables that aren't destroyed when the function exit. So when the function is called again, it keeps the value of the static variable.
member static variable is a variable that is defined in a class. It is accessible by all the functions plus the static functions. All the instances of the class access exactly the same variable. (only one copy is kept for all the instances)
There's is also static functions. Static functions are only accessible at the file scope, and static member functions are functions that cannot access member variables of the class, only the static ones.
Hope it helps!
Marc-Antoine