标签:iter 对象 pause string insert value 地址 include util
#include <string>
#include <iostream>
#include <map>
#include <utility>
using namespace std;
int main()
{
map<int, string> Employee;
//通过键值赋值
Employee[123] = "Mayuefei";
//通过成员函数insert和STL的pair赋值
Employee.insert(pair<int, string>(132, "Liaoyuanqing"));
//通过value_type赋值
Employee.insert(map<int, string>::value_type(124, "Liyiyi"));
//通过make_pair赋值
Employee.insert(make_pair(234, "LLK.D"));
for (map<int, string>::iterator it = Employee.begin(); it != Employee.end(); it++)
{
cout<<(*it).first<<":"<<(*it).second<<endl;//取值操作
}
system("pause");
return 1;
};
转载地址:http://blog.csdn.net/nokianasty/article/details/6026949
标签:iter 对象 pause string insert value 地址 include util
原文地址:http://www.cnblogs.com/Stephanie7464/p/6727963.html