Skip to content

Instantly share code, notes, and snippets.

@illescasDaniel
Created October 24, 2016 11:32
Show Gist options
  • Save illescasDaniel/a634517d54b99e905d4dd1ee649152c4 to your computer and use it in GitHub Desktop.
Save illescasDaniel/a634517d54b99e905d4dd1ee649152c4 to your computer and use it in GitHub Desktop.
Map / Dictionary [C++]
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(int argc, char *argv[]) {
map<string,int> dic;
dic["hi"] = 10;
dic["bye"] = 20;
cout << dic["hi"] << endl;
for (auto value: dic) {
cout << value.first << ": " << value.second << ", ";
}
cout << endl;
//
string hola = "how are you?";
map<string,int> dic2 = {{"test", 11}, {hola, 20}};
cout << dic2["test"] << endl;
cout << dic2[hola] << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment