map的4种插入方式
2017-09-18 18:11
190 查看
#include<string>
#include<iostream>
#include<map>
#include<utility>
usingnamespacestd;
intmain()
{
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;
};
顶4踩0
#include<iostream>
#include<map>
#include<utility>
usingnamespacestd;
intmain()
{
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;
};
顶4踩0
相关文章推荐
- map容器对象插入数据的4种方式讲解
- map的4种常见的插入元素的方式及区别
- map容器对象插入数据的4种方式
- map的4种常见的插入元素的方式及区别
- map容器对象插入数据的4种方式
- map容器对象插入数据的4种方式讲解
- map容器对象插入数据的4种方式讲解
- map容器对象插入数据的4种方式讲解
- map和4种输出方式
- Map集合的4种遍历方式
- mybatis以map的方式批量插入list集合数据操作步骤
- map的4种遍历方式
- map元素的插入方式
- Map的4种遍历方式
- map容器插入数据之 map[] 和 insert 方式的分析
- map的4种遍历方式
- map容器元素的三种插入方式
- 遍历map集合对象的4种方式
- map容器的三种插入方式
- STL中map容器的元素插入方式