0
からプライベート静的メンバにアクセスするC++私はそう実装ファイル
#ifndef MYAPP
#define MYAPP
#include <map>
namespace MyApp{
class MyClass{
private:
static std::map<int, bool> SomeMap;
public:
static void DoSomething(int arg);
};
}
#endif MYAPP
のようなヘッダファイルを持っているとimplemtationファイル
#include "Header.h"
#include <map>
namespace MyApp{
void MyClass::DoSomething(int arg){
if(MyClass::SomeMap[5]){
...
}
}
}
、それは私にエラークラスを提供します"MyClass"にはメンバー "SomeMap"はありません。これをどうすれば解決できますか?
#include "Header.h"
#include <map>
namespace MyApp{
std::map<int, bool> MyClass::SomeMap;
void MyClass::DoSomething(int arg){
if(MyClass::SomeMap[5]){
...
}
}
}
P.S.:
[静的なクラスメンバへの未定義の参照]の可能な複製(https://stackoverflow.com/questions/272900/undefined-reference-to-static-class-member) – user4581301