#include #include #include #include "Printer.h" using namespace std; void PrintOut(const pair &p) { cerr << "printout [" << p.first << "," << p.second << "]" << endl; } int main(int argc, char **argv) { Printer a, b, c, d, e, f; map table; // Instead of embedding derivatives of the type of table // in multiple places in the code, as in the commented declaration // here, we use 'auto' (in the code body below) // map::iterator it; table.insert(pair(a, b)); table[c] = d; table[e] = f; cout << "table[e]:" << table[e] << endl; auto it = table.find(c); cout << "PrintOut(*it), where it = table.find(c)" << endl; PrintOut(*it); cout << "iterating:" << endl; for_each(table.begin(), table.end(), &PrintOut); return 0; }