map容器对象插入数据的4种方式讲解
2016-10-11 14:43
274 查看
转载自:http://blog.csdn.net/nokianasty/article/details/6026949
map容器对象插入数据的4种方式
#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赋值<strong>
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;
};
map容器对象插入数据的4种方式
#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赋值<strong>
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;
};
相关文章推荐
- map容器对象插入数据的4种方式讲解
- map容器对象插入数据的4种方式讲解
- map容器对象插入数据的4种方式讲解
- map容器对象插入数据的4种方式
- map容器对象插入数据的4种方式
- map容器插入数据的4种方法
- map容器插入数据之 map[] 和 insert 方式的分析
- map容器元素的三种插入方式
- hibernate系列二:hibernate中java对象的三种状态及数据更新的4种方式
- java方式的将java对象以及list或者map转化为json数据,json转换为object或者map
- mybatis以map的方式批量插入list集合数据操作步骤
- java方式的将java对象以及list或者map转化为json数据 .
- map的4种常见的插入元素的方式及区别
- 遍历map集合对象的4种方式
- map关联容器问题,内部数据按照键值的大小排序,无论插入数据的顺序!
- java方式的将java对象以及list或者map转化为json数据
- map容器的三种插入方式
- map的4种插入方式
- STL中map容器的元素插入方式
- java方式的将java对象以及list或者map转化为json数据