// PL10/mapdemo.cpp // illustrates the use of the map containetr class // Niels Walet. Last edited 03/12/2019 #include #include #include #include // Use alias for our type of map typedef std::map international_dial_codes; void search_database(international_dial_codes &dial_codes, int code_search) { international_dial_codes::iterator dial_codes_iter; dial_codes_iter = dial_codes.find(code_search); if(dial_codes_iter != dial_codes.end()) std::cout<<"Found country for dial code " <(672,"Christmas Island")); // How many entries so far? std::cout<<"Size of database = "<first <<", country: " << dial_codes_iter->second << std::endl; // What country has code 672? Let's find out (uses iterator) int code_search(672); search_database(dial_codes,code_search); // Again for a code not stored code_search = 673; search_database(dial_codes,code_search); return 0; }