Static Data: Example
// note, private protection is default
static int a = 0; // only static members can be initialized
// this way; normally, use the constructor
sample() { a++; b=0; printf("STARTING: a=%d, b=%d\n", a, b); }
~sample() { printf("FINISHED: a=%d, b=%d\n", a, b); a--; b--; }
// memory for the static member must be defined somewhere!
// you could also initialize "a" here instead of in the class
sample s1; // STARTING: a=1, b=0
sample s2; // STARTING: a=2, b=0
sample s3; // STARTING: a=3, b=0
// FINISHED: a=3, b=0… FINISHED: a=2, b=0… FINSIHED: a=1, b=0