迭代器之map的简单介绍

来源:互联网 发布:淘宝客服名称 编辑:程序博客网 时间:2024/05/28 15:07
#include<iostream>
#include<string>
#include<map>
using namespace std;

//typedef map<int,string> UDT_MAP_INT_STRING;
//UDT_MAP_INT_STRING enumMap;

int main()
{
    cout<<"........"<<endl;
    map<int,string> enumMap;
    enumMap.insert(pair<int,string>(1,"student_one"));
    enumMap.insert(pair<int,string>(2,"student_two"));
    enumMap.insert(pair<int,string>(3,"student_third"));
    enumMap.insert(pair<int,string>(3,"student_third"));
    enumMap.insert(pair<int,string>(3,"student_third"));
    enumMap.insert(pair<int,string>(3,"student_third"));
    map<int,string>::iterator iter;
    for(iter=enumMap.begin();iter!=enumMap.end();iter++)
    {
        cout<<iter->first<<""<<iter->second;
        cout<<""<<endl;
    
    }
    getchar();
}


先把代码贴出来,随后进行深入了解

0 0
原创粉丝点击