Created
September 19, 2017 04:12
-
-
Save poanchen/58a116084a31973f0d169915c2cb9240 to your computer and use it in GitHub Desktop.
Create a std::map and insert into it the key-value pairs {“one”,1}, {“two”,2}, and {“three”,3}.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://repl.it/LO2s | |
#include <iostream> | |
#include <map> | |
using namespace std; | |
int main() | |
{ | |
std:map <string, int> intMap; | |
intMap.insert(std::pair <string, int> ("one", 1)); | |
intMap.insert(std::pair <string, int> ("two", 2)); | |
intMap.insert(std::pair <string, int> ("three", 3)); | |
std::map<string, int>::iterator it = intMap.begin(); | |
cout << "intMap holds: \n"; | |
for (it=intMap.begin(); it!=intMap.end(); ++it) { | |
std::cout << it->first << " => " << it->second << '\n'; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment