class A { private: static int a; //声明但未定义 static std::map<std::string,int>fileMap; }; int A::a = 3; //定义了 std::map<std::string, int> YuvMap::fileMap = std::map<std::string, int>();
#include <iostream> #include <map> using namespace std; class A { public: static map<int,int> m; }; map<int,int> A::m; int main() { A::m.insert(make_pair(1,2)); return 0; }
原文:https://www.cnblogs.com/jiulonghudefeizhai/p/11191413.html