static member variable when declared private
问题 When a static member variable is declared private in a class, how can it be defined? Suppose i have the following class declaration class static_demo { private: static int a; public: static int b; void set(int x, int y) { a = x; b = y; } void show() { cout << "a = " << a << "\n"; cout << "b = " << b << "\n"; } }; Then the following statement to define a will result in compilation error. int static_demo::a; So is it possible to have a static data member in the private section of class? Adding