map erase issue
Hi,
Suppose there is a map (key:integer, value: object) which is not empty as below,
I want to know if the object is still available after erase?
1 2 3 4 5 6 7
|
map<int,string> mymap;
mymap[0] = "sssss";
map<int,string>::iterator itr = mymap.find(0);
string& s = itr->second;
//or string* s = &(itr->second);
mymap.erase(0);
printf("RRR %s\n", s.c_str());
|
Regards,
Dophine
Last edited on
No it's not still available, so your call to s.c_str() results in undefined behavior.
Topic archived. No new replies allowed.