Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Myclass.h の内部
Class Myclass { public: Myclass(); private: static int Myarray[12]; };
上記の静的配列を初期化する方法は?
ファイルで1回だけ定義する必要があります。.cpp
.cpp
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. */
投稿されたコードは、配列の宣言にすぎません。