You are viewing a single comment's thread. Return to all comments →
const std::string fruit_strs[] = {"apple", "orange", "pear"}; const std::string color_strs[] = {"red", "green", "orange"}; template <class T> class Traits { public: static std::string name(const int index) { if (index >= 0 && index < 3) { if (typeid(T) == typeid(Fruit)) return (fruit_strs[index]); if (typeid(T) == typeid(Color)) return (color_strs[index]); } return ("unknown"); } };
Seems like cookies are disabled on this browser, please enable them to open this website
C++ Class Template Specialization
You are viewing a single comment's thread. Return to all comments →