#include #include #include #include #include "Student.hpp" template void print(std::map s) { for(auto it = s.cbegin(); it!=s.cend(); it++) std::cout << it->first << " -> " << it->second << std::endl; } 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 ); try { students.at( Student("Peter Pan", 1234) ) = std::string("Home Under The Ground, Neverland"); } catch(std::out_of_range& ex) { std::cout << "Student '" << Student("Peter Pan", 1234) << "' does not exist in map\n\n"; } try { students.at( Student("Minnie Mouse", 1240) ) = std::string("Walt Disney World Communications, P.O Box 10040, Lake Buena Vista, Florida 32830-0040 "); } catch(std::out_of_range& ex) { std::cout << "Student '" << Student("Minie Mouse", 1240) << "' does not exist in map\n\n"; } print(students); }