C++ 맵

Jmnote (토론 | 기여)님의 2024년 2월 3일 (토) 19:05 판 (→‎같이 보기)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

C++ 맵
#include <iostream>
#include <map>
using namespace std;

int main() {
    map<string, int> m;
    m["x"] = 40;
    m["y"] = -74;
    
    for(auto it=m.begin(); it!=m.end(); it++) {
        cout << it->first << ':' << it->second << endl;
    }
}
#include <iostream>
#include <map>
using namespace std;

int main() {
    map<string, int> m = {{"x",40}, {"y",-74}};
    for(auto& it: m) {
        cout << it.first << ':' << it.second << endl;
    }
}
#include <iostream>
#include <map>
using namespace std;

int main() {
    map<string, int> m = {{"x",40}, {"y",-74}};
    cout << m["foo"];
}

2 멤버 함수[ | ]

3 같이 보기[ | ]

4 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}