#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
void insertItem(unordered_map<int, string>& items, const int& key, const string& value) {
items.insert(unordered_map<int, string>::value_type(key, value));
}
string getItem(unordered_map<int, string>& items, const int& key) {
return items[key];
}
void main() {
unordered_map<int, string> items;
insertItem(items, 0, "Park");
insertItem(items, 1, "Kim");
insertItem(items, 2, "Hong");
insertItem(items, 3, "Choi");
for (int i = 0; i < 4; i++) {
printf("%d - %s\n", i, getItem(items, i).c_str());
}
}
'컴퓨터 공학 > C++' 카테고리의 다른 글
const_cast 사용 예시 (0) | 2019.11.14 |
---|---|
C++ exit()와 quick_exit()의 차이점 (0) | 2019.05.24 |
[C/C++] 윈도우즈 운영체제에서 맥 주소 가져오기 (0) | 2018.09.18 |
[c/c++] Boost 주요 기능 정리 (0) | 2018.09.12 |
C언어 - rand()를 이용한 난수 생성 (0) | 2018.09.12 |