template specialization | Sololearn: Learn to code for FREE!

+1

template specialization

template <class T> class MyClass { public: MyClass (T x) { cout <<x<<" - not a char"<<endl;// please tell me that why did we write here x after cout? } };

10/25/2017 2:25:06 PM

Shivani Goyal

3 Answers

New Answer

+3

That depends on the purpose. In the code in the Course, it was to print the value and show that x was not of type char. Then they specialized the class for the char type and printed, 'x' is a char. This was possible, as they wrote a seperate class for the type char.

+2

answer is <> and int.

+1

answer is <> and char.