"C++ 맵"의 두 판 사이의 차이

 
74번째 줄: 74번째 줄:
* [[C++ 벡터]]
* [[C++ 벡터]]
* [[C++ 자료형]]
* [[C++ 자료형]]
* [[C언어 해시 테이블 구현]]
* [[Go 맵]]
* [[Go 맵]]
* [[Java 해시맵]]
* [[Java 해시맵]]

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