posted 22 years ago
Basically, if you have multiple objects of a class, and the class has a static variable (or class variable, as Christopher pointed out), each object does not get its own copy of the variable, they all use the same one. Here's a simple example:
The output here is:
1
2
Why not two 1's?? Because variable is static, there is only one instance of it, so all objects of MyClass access the same variable.
If we had not declared variable as static, then object a would have its own copy of variable, and object b would have its own copy.
Clear as mud?
Jason
[This message has been edited by jason adam (edited August 20, 2001).]