#include<iostream>
#include<map>
using namespace std;
int main ( )
{
// Declaration
map<string,double>
M;
// Assignment
M.insert
(make_pair("Sony",100.0));
M.insert (make_pair("JVC",120.0));
M["Philips"] = 120.0;
M["Samsung"] = 130.0;
M.insert(map<string,double> ::
value_type("Siemens",140));
// Declaration of the iterator pos
map<string,double>
:: iterator pos;
// Print M
for
(pos=M.begin( );pos!=M.end( );++pos) {
cout << pos->first << ": price = $" <<
pos->second << endl;
}
// "Siemens" is replaced by "Sie" (exchanging
elements)
M["Sie"]=M["Siemens"];
M.erase("Siemens");
// Prices rise: +25%
for
(pos=M.begin( );pos!=M.end( );++pos) {
pos->second *=1.25;
}
// Print M
cout <<
endl;
for
(pos=M.begin( );pos!=M.end( );++pos) {
cout << pos->first << " price = $" <<
pos->second << endl;
}
}