#include <iostream>
#include <map>
using namespace std;
int main()
{
map<string,string> testMap{
{"cpp","cpppp"},
{"java","javaaaa"},
{"shell","shelllll"},
{"python", "pythonnnn"}
};
map<string,string>::iterator it;
for(auto& var : testMap)
{
cout<<var.first << " "<<var.second<<endl;
}
cout<<"==================================="<<endl;
for(it=testMap.begin();it!=testMap.end();++it)
{
if(it->first=="cpp")
{
cout<<"del first==cpp"<<endl;
cout<<it->second<<endl;
cout<<"del first==cpp"<<endl;
testMap.erase(it++);
}
cout<<it->first << it->second<<endl;
}
cout<<"==================================="<<endl;
return 0;
}
refer to other acticles
|