#include "stdafx.h"
#include <map>
#include<string>
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
map<string,int> map_list;
map<string,int>::iterator it;//맵 인덱스 값
//pair구조를 사용하는 방법
pair<string,int> data1("홍길동",10);
map_list.insert(data1);
pair<string,int> data2("강기태",22);
map_list.insert(data2);
pair<string,int> data3("나정훈",25);
map_list.insert(data3);
pair<string,int> data4("김성철",40);
map_list.insert(data4);
map_list.erase("홍길동");
//맵에서 데이터를 출력하기
for (it=map_list.begin();it != map_list.end();++it)
{
cout<<it->first<<": "<<it->second<<endl;
}
cout<<endl<<endl;
map<int,string> mymap;
map<int,string>::iterator pos;
pair<int,string>Dt1(2,"바나나");
mymap.insert(Dt1);
pair<int,string>Dt2(12,"포도");
mymap.insert(Dt2);
pair<int,string>Dt3(32,"사과");
mymap.insert(Dt3);
pair<int,string>Dt4(22,"복숭아");
mymap.insert(Dt4);
///출력
for (pos = mymap.begin();pos!=mymap.end();++pos)
{
cout<<pos->first<<" : "<<pos->second<<endl;
}
return 0;
}