作业帮 > 综合 > 作业

c++中关于map的知识

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/26 12:54:32
c++中关于map的知识
请各位前辈给我详细介绍介绍map的用法(c或c++)!它有什么作用,什么特点,怎么用?
1.map的构造函数
Map mapStudent;
2. 数据的插入
在构造map容器后
第一种:用insert函数插入pair数据
#pragma warning (disable:4786) )
#include
#include
#include
Using namespace std;
Int main()
{
Map mapStudent;
mapStudent.insert(pair(1, “student_one”));
mapStudent.insert(pair(2, “student_two”));
mapStudent.insert(pair(3, “student_three”));
map::iterator iter;
for(iter = mapStudent.begin(); iter != mapStudent.end(); iter++)
{
Cout