Hi all,
I want to store some data pairs. A variable name and the value. I've try it in this way.
//data map testing
map<string, int> my_map;//map
map<string, int>::iterator my_it;//map iterator
my_map["first"]=10;
my_map["second"]=12;
string ss = "third";
my_it = my_map.find(ss);
if(my_it == my_map.end())
{
//insert new value
my_map["third"] = 15;
}
else
{
//update the exsiting value
my_map.erase(my_it);
}
I think my code is clear to you. Insert string,int pair. Before that I want to check that same string are in the map. If so I want to change the value only, with the existing one, not the variable name. Thats the point I've stuck. Can you guys give me a help on this.