Inside Myclass.h
Class Myclass { public: Myclass(); private: static int Myarray[12]; }; How to initialize the above static array ?
You need to define it exactly once, in a .cpp file:
int MyClass::MyArray[12] = { 0, 1, 2 }; /* Definition and initialisation. Any elements not explicity initialised will be value-initialised, 0 in the case of int. */ The posted code is only a declaration of the array.