您的位置:首页 > 编程语言 > C语言/C++

C++ map容器的2种初始化方法

2011-12-30 16:43 363 查看
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main()
{
map<string, int> map1;
map1[string("tttt")] = 1;
map1[string("ggg")] = 2;
map1.insert(pair<string, int>("niubi", 3));
map<string, int>::iterator it = map1.begin();
while ( it != map1.end())
{

cout<<it->first<<" "<<it->second<<endl;
it++;
}
system("pause");
return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: