#include<iostream>
#include<string>
#include<map>
using namespace std;
void printCarInfo(map <string,string> &carinfo){
cout<<"----------------------------------------------"<<endl;
map <string, string>::iterator it1;
for(it1 = carinfo.begin(); it1 != carinfo.end(); it1++){
cout<<it1->first<<" : "<<it1->second<<endl;
}
}
int main(void){
map <string, string> carinfo;
carinfo.insert(map<string, string>::value_type("itemType", "auto"));
carinfo.insert(make_pair("subtype", "4WD"));
carinfo["make"] = "Jeep";
carinfo["year"] = "1998";
carinfo["color"] = "green";
//Insert Key-Value Pair
printCarInfo(carinfo);
map <string, string>::iterator FindIter = carinfo.find("year");
if(FindIter != carinfo.end()){
FindIter->second = "2002";
}
//Lookup & Reassign
printCarInfo(carinfo);
carinfo["year"] = "2013";
//Reassign
printCarInfo(carinfo);
carinfo.erase("year");
//delete
printCarInfo(carinfo);
}
[PNG image (25.48 KB)]