#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;
//cout<<"Hello World";
for(auto& var : testMap)
{
cout<<var.first << " "<<var.second<<endl;
}
cout<<"==================================="<<endl;
for(it=testMap.begin();it!=testMap.end();++it)
{
//cout<<it->first << it->second<<endl;
if(it->first=="cpp")
{
cout<<"del first==cpp"<<endl;
cout<<it->second<<endl;
cout<<"del first==cpp"<<endl;
testMap.erase(it++);
//cout<<"cpp "<<it->second<<endl;
}
cout<<it->first << it->second<<endl;
}
cout<<"==================================="<<endl;
// for(auto& var : testMap)
// {
// cout<<var.first << " "<<var.second<<endl;
// }
// for(map<string,string>::iterator it2=testMap.begin();it2!=testMap.end();++it2)
// {
// cout<<it2->first << it2->second<<endl;
// }
return 0;
}
refer to other acticles