#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 << " goes " << p.second << endl; } // For those curious... https://youtu.be/jofNR_WkoCE // ... enjoy? int main(int argc, char** argv) { map animals; animals["dog"] = "woof"; animals["cat"] = "meow"; animals["fish"] = "blub"; animals["seal"] = "ow ow ow"; animals["fox"]; if (animals.find("fox") == animals.end()) { cout << "not found" << endl; } else { cout << "found" << endl; } cout << "iterating:" << endl; for_each(animals.begin(), animals.end(), &PrintOut); return EXIT_SUCCESS; }