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_dem
The problem is not the definition, but the fact that in main() (that's not in the name scope of static_demo, and cannot see a being private), you do an assignment.
The definition of a is what you did at global scope, with int static_demo::a;.
You simply need an initializer, if you want a not to start with an undefined value.
int static_demo::a = 1;
will solve the problem.
From than on, a can be manipulated only by functions in static_demo (of friend of it).