====== C - C++ Templates - Class Template specialization ====== #include using namespace std; template class specific { T value; public: specific(T a) { cout << "Generic specific\n"; value = a; } T getvalue() { return value; } }; // Explicit specialization for float. template <> class specific { int value; public: specific(float a) { cout << "Specific specialization\n"; value = a * a; } int getvalue() { return value; } }; int main() { specific d('a'); cout << "Character value: " << d.getvalue() << "\n\n"; specific i(2.2); cout << "Float value: " << i.getvalue() << "\n"; return 0; }