// A1.2.cpp : Defines the entry point for the console application. // // Please provide the definition of a template-based function // that returns a string representation of the template type. #pragma unmanaged #include "stdafx.h" #include #include #include //// answer //////////////////////////////////////////////////// template std::string templateType(const T &t) { return typeid(T).name(); } //////////////////////////////////////////////////////////////// int _tmain(int argc, _TCHAR* argv[]) { std::cout << "\n Exam A1 - Question #2 " << "\n =======================\n"; int i = 0; std::cout << "\n " << templateType(i).c_str() << "\n"; double d = 0; std::cout << "\n " << templateType(d).c_str() << "\n"; std::vector v; std::cout << "\n " << templateType(v).c_str() << "\n"; std::cout << std::endl; return 0; }