C++静态成员变量map如何初始化赋值

class a {
public:
    typedef std::map<int, int> urlMap;
    static urlMap mp;
    static urlMap CreateMap() {
        urlMap tmp_map = { {1, 1},{2, 2},{3, 3} };
        return tmp_map;
    }

};
a::urlMap a::mp = a::CreateMap();

int main()
{
    std::map<int, int>::iterator it = a::mp.begin();
    while (it != a::mp.end())
    {
        cout << it->first << " "<< it->second <<endl;
        it++;
    }
    return 0;
}

原文地址:https://www.cnblogs.com/Galesaur-wcy/p/15188301.html