#include #include using namespace std; // // Declare a map container using an int as a key and containing // a string as the data. // use the less<> algorithm to order the map // typedef map > ISMap; // // prints a pair. // template ostream& operator<< (ostream& out, const pair & p) { cout << "First: "<(cout,"\n") ); return out; } void main() { // // instantiate a map // ISMap m; // // value_type in the case of a map refers to the pair structure which // contains the two key / data values. // typedef ISMap::value_type value_type; // // insert the values // m.insert(value_type(1, string("One"))); m.insert(value_type(2, string("Two"))); m.insert(value_type(4, string("Four"))); m.insert(value_type(5, string("Five"))); // // print the map. // cout << m << endl; // // find value 2. // ISMap::iterator p = m.find(2); // // print value found if found, else final value // cout << *p; // // advance iterator one element and print value // advance(p,1); cout << *p; cout << "\nPress any key to exit... "; while ( !cin.get() ) ; };