关于类中的 static vector 变量 - C-C++ - C++ 语言
http://topic.csdn.net/u/20081021/18/658c5ca3-875a-478b-86c0-b75b35bda2b8.html
简单例子:
- C/C++ code
-
//A.h #include <vector> #include <string> using namespace std; class A { public: static vector <string> v; };
- C/C++ code
-
//A.cpp #include "A.h" vector <string> A::v;
- C/C++ code
-
//main.cpp #include "A.h" #include <iostream> using namespace std; int main() { A::v.push_back("asd"); cout<<A::v[0]<<endl; }