#include #include #include #include #include "Student.hpp" int main() { std::pair peter_pan(Student("Peter Pan", 1234), std::string("Wendy House, Neverland")); std::pair mickey_mouse = make_pair(Student("Mickey Mouse", 1235), std::string("Walt Disney World Communications, P.O Box 10040, Lake Buena Vista, Florida 32830-0040 ")); std::map students; students.insert( peter_pan ); students.insert( mickey_mouse ); std::string address_pp; std::string address_mm; try { address_pp = students.at(Student("Peter Pan", 1234)); // address_pp exists } catch(std::out_of_range& ex) { std::cout << "Student '" << Student("Peter Pan", 1234) << "' does not exist in map\n\n"; } try { address_mm = students.at(Student("Minie Mouse", 1240)); // address_mm does not exist } catch(std::out_of_range& ex) { std::cout << "Student '" << Student("Minie Mouse", 1240) << "' does not exist in map\n\n"; } std::cout << "Peter Pan address: " << address_pp << std::endl; std::cout << "Minie Mouse address: " << address_mm << std::endl; // empty string }