#include #include #include using std::cout; using std::endl; using std::map; using std::pair; using std::string; void PrintOut(const pair& p) { cout << p.first << " says " << p.second << endl; } // For those curious... https://youtu.be/jofNR_WkoCE // ... enjoy? int main(int argc, char** argv) { map animals; animals["dog"] = "woof"; animals["cow"] = "moo"; animals["cat"] = "meow"; animals["fish"] = "blub"; // originally "" animals["seal"] = "ow ow ow"; // originally "honk" animals["fox"]; auto it = animals.find("fox"); if (it == animals.end()) { cout << "fox not found" << endl; } else { cout << "fox found!" << endl; } cout << "iterating:" << endl; for_each(animals.begin(), animals.end(), &PrintOut); return EXIT_SUCCESS; }