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
in your .cpp:
int static_demo::a(0);
when this causes an error, it is most common that you either encountered a linker error for a multiply defined symbol (e.g. the definition was in the header), or that you may have tried to define it in the wrong scope. that is, if static_demo is in the namespace MON, it would be defined in the .cpp:
#include "static_demo.hpp"
int MON::static_demo::a(0);
for other types, it may simply have been an incorrect constructor.