C++ 맵

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 }}