We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
C++ Class Template Specialization
C++ Class Template Specialization
Sort by
recency
|
124 Discussions
|
Please Login in order to post a comment
include
using namespace std; enum class Fruit { apple, orange, pear }; enum class Color { red, green, orange };
template struct Traits;
template <> struct Traits { static string name(int index) { switch (index) { case 0: return "red"; case 1: return "green"; case 2: return "orange"; default: return "unknown"; } } };
template <> struct Traits { static string name(int index ) { switch (index) { case 0: return "apple"; case 1: return "orange"; case 2: return "pear"; default: return "unknown"; } } };
int main() { int t = 0; std::cin >> t;
}
// We can represent enums like numbers
i thing it like that rule