对map, vector类型的静态成员初始化

来源:互联网 发布:投标书制作软件 编辑:程序博客网 时间:2024/04/30 04:05

#pragma warning(disable:4786)

#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

class Test
{
public:
 static map<string, int> testMap;
 static vector<int> vecInt;
 Test();
private:
 static int sInt;
 int n;
};

int Test::sInt = 0;
map<string, int> Test::testMap;
vector<int> Test::vecInt;

Test::Test()
{
 testMap["a"] = 1;
 vecInt.push_back(1);
 n = 1;
 sInt += n;
}


int main()
{
 Test test;
 return 0;
}

 

原创粉丝点击