posted by Kyleslab 2010. 12. 10. 17:35


// Table.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//

#include "stdafx.h"

#include <map>
#include <string>
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
 map<string, int> table;

 table["abc"] = 10;
 table.insert( make_pair("due",20));// pair 두개의 자료를 하나의 자료로 묶어준다.
 /*pair<int, int> a;
 a.first;
 a.second;
 */
 //map< string, int >::iterator iter;
 auto iter =table.begin();
 for(;
  iter !=table.end();
  ++iter )
 {
  cout<<(*iter).first<<(*iter).second<<endl;
 }

 cout<<table["abc"]<<endl;// 이방식은 거의 사용안함 안의 인덱스가 없는것들도 접근이 가능하므로 위험하다.

 iter = table.find("abc");
 cout<<(*iter).second<<endl;

 cout<<table["asdfasdf"]<<endl;

 return 0;
}

 

'Operations Dev > Handle' 카테고리의 다른 글

HandleBased Operation System  (0) 2010.12.10