【发布时间】:2017-12-15 06:04:09
【问题描述】:
我有一个这样的头文件
#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
和一个实现文件
#include "Header.h"
#include <map>
namespace MyApp{
void MyClass::DoSomething(int arg){
if(MyClass::SomeMap[5]){
...
}
}
}
当我尝试编译它时,它给了我一个错误class "MyClass" has no member "SomeMap"。我该如何解决这个问题?
【问题讨论】:
标签: c++ implementation static-variables