* Computer Science/C++
vector pair 사용
soicem
2018. 3. 22. 14:04
캐시를 하려하는데 vector에 튜플 형식으로 변수가 들어가는 것을 원하던 중 pair라는 구문을 발견, 그러나 2개만 들어가게 만들어놓은 이유는 무엇인지...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <iostream> #include <fstream> #include <string> #include <vector> using namespace std; vector<pair<string, int>> cache; int main() { string a = "soicem"; cache.resize(1000); cache[10] = make_pair(a, 100); cout << cache[10].first << endl; cout << cache[10].second << endl; system("pause"); return 0; } | cs |