map容器插入数据的4种方法
来源:互联网 发布:java调用golang 编辑:程序博客网 时间:2024/05/20 21:58
在构造map容器后,我们就可以往里面插入数据了。这里讲四种插入数据的方法:
第一种:用insert函数插入pair数据:在VC下请加入这条语句,屏蔽4786警告 #pragma warning (disable:4786) )
- map<int, string> mapStudent;
- mapStudent.insert(pair<int, string>(1, "student_one"));
- mapStudent.insert(pair<int, string>(2, "student_two"));
- mapStudent.insert(pair<int, string>(3, "student_three"));
- map<int, string> mapStudent;
- mapStudent.insert(map<int, string>::value_type (1, "student_one"));
- mapStudent.insert(map<int, string>::value_type (2, "student_two"));
- mapStudent.insert(map<int, string>::value_type (3, "student_three"));
- map<int, string> mapStudent;
- mapStudent.insert(make_pair(1, "student_one"));
- mapStudent.insert(make_pair(2, "student_two"));
- mapStudent.insert(make_pair(3, "student_three"));
第四种:用数组方式插入数据,下面举例说明
- map<int, string> mapStudent;
- mapStudent[1] = "student_one";
- mapStudent[2] = "student_two";
- mapStudent[3] = "student_three";
阅读全文
0 0
- map容器插入数据的4种方法
- map容器对象插入数据的4种方式讲解
- map容器对象插入数据的4种方式
- map容器对象插入数据的4种方式讲解
- map容器对象插入数据的4种方式讲解
- map容器对象插入数据的4种方式讲解
- map容器的四种插入元素方法
- map容器的三种插入方式
- map中插入数据的三种方法
- C++ map 的两种插入数据方法
- map容器插入数据之 map[] 和 insert 方式的分析
- map容器(4种元素添加方法的异同)
- map容器元素的三种插入方式
- map关联容器问题,内部数据按照键值的大小排序,无论插入数据的顺序!
- STL中map容器的元素插入
- c++ map容器的元素插入
- c++<map>容器的方法
- MongoDB:4种插入数据的方法
- 构造函数的作用,无参构造和有参构造
- 心急的C小加
- js中的substring 和substr的区别
- JAVA 基础知识 面试题
- OpenThreads线程管理
- map容器插入数据的4种方法
- 嵌入式学习18(C++)
- Party Games UVA
- CentOS 6.5上安装JIRA 6.3.6
- db2常用命令大全 db2数据库中的操作命令
- 如何实现Springboot+mybaitis动态查询与关联查询?
- python连接远程MySQL数据库
- java 正则表达式
- MOOC清华《程序设计基础》第8章:以文本文件存储链表