Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://stackoverflow.com/questions/21815462/enter-standard-input-for-values-of-map
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- map<int, string> name_map;
- name_map[1] = "Tom";
- name_map[2] = "Max";
- name_map[3] = "Mark";
- name_map[4] = "John";
- name_map[5] = "Patrik";
- name_map.insert(pair<int, string>(6, "Jauly"));
- name_map.insert(pair<int, string>(7, "Jack"));
- cout << "is empty?: " << name_map.empty() << endl;
- cout << "map size: " << name_map.size() << endl;
- map<int, string>::iterator it = name_map.find(5);
- cout << "key found = " << it->second << endl;
- name_map.erase(it);
- for(map<int, string>::iterator it = name_map.begin(); it != name_map.end(); it++){
- cout << it->first << " => " << it->second << endl;
- }
- name_map.clear();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement