// MT1Q2.cpp #include #include #include #include #include #include #include template std::string show(const C& con) { std::ostringstream out; C::const_iterator iter; std::cout << "\n "; for(iter=con.begin(); iter!=con.end(); ++iter) { out << *iter << " "; if(typeid(*iter) == typeid(std::string)) out << "\n "; } return out.str(); } void main() { std::string myFriends[] = { "Terminator", "Jack The Ripper", "Lucretia Borgia", "Attila the Hun", "Genghis Khan" }; int myNumbers[] = { 0, 1, 2, 3, 2, 1, 0 }; std::vector vecfriends(myFriends, myFriends+5); std::cout << show(vecfriends) << "\n"; std::list lstfriends(myFriends, myFriends+5); std::cout << show(lstfriends) << "\n"; std::set setfriends(myFriends, myFriends+5); std::cout << show(setfriends) << "\n"; std::list lstNumbers(myNumbers, myNumbers+7); std::cout << show(lstNumbers) << "\n"; std::cout << "\n"; }