hi all,
thank all of you who had replied to my question.
i'd like to summarize my question and make sure
i understand right.
case 1:
if you declare static variable outsize of the class,
that means the variable is global. so that, it is possible
to access the static variable from outsize of a object.
static int counter = 0;
class base {
public:
base(void) {counter++;}
~base(void){counter--;}
int get_counter(void) {return counter;}
};
int main(void) {
base b;
counter += 1; // this is ok;
cout << b.get_counter(); // this prints 2
}
case2:
you should initialize(or define?) static variable
outside of the class declaration.
case3:
because, in my example, static variable is private,
you need a static function if you want to access to
that static variable without an object.
regards,
yashi