C++ define map code example
Example 1: map declaration c++
//assuming your variables are called : variables_
#include <map>
#include <string>
std::map<int, std::string> map_;
map_[1] = "mercury";
map_[2] = "mars";
map_.insert(std::make_pair(3, "earth"));
//either synthax works to declare a new entry
return map_[2]; //here, map_[2] will return "mars"
Example 2: map in cpp
#include <map>
int main(){
//new map
std::map <int,int> myMap;
myMap[0] = 1;
myMap[1] = 2;
myMap[2] = 3;
myMap[3] = 4;
}