map functionc++ code example
Example: map c++
#include <iostream>
#include <string>
#include <map>
using std::string;
using std::map;
int main() {
// A new map
map<string, int> myMap = { // This equals sign is optional
{"one", 1},
{"two", 2},
{"three", 3}
};
// Print map contents with a range-based for loop
// (works in C++11 or higher)
for (auto& iter: myMap) {
std::cout << iter.first << ": " << iter.second << std::endl;
}
}