c++ mapping code example
Example 1: map in c
#include <map>
std::map<size_t, std::string> map;
map[10] = "Hello";
map[1] = "boys";
map[901] = "girls"
Example 2: map c++
#include <iostream>
#include <string>
#include <map>
using std::string;
using std::map;
int main() {
map<string, int> myMap = {
{"one", 1},
{"two", 2},
{"three", 3}
};
for (auto& iter: myMap) {
std::cout << iter.first << ": " << iter.second << std::endl;
}
}
Example 3: map of maps c++
map <typename,map<typename,typename>> mp;
map[key1][key2]=values