template specialization | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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? } };

25th Oct 2017, 2:25 PM
Shivani Goyal
4 Answers
+ 5
answer is <> and int.
22nd May 2020, 4:11 AM
LANKA ATRI DATTA RAVI TEZ
LANKA ATRI DATTA RAVI TEZ - avatar
+ 4
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.
25th Oct 2017, 2:46 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
0
The a nswer is <> and int
29th Aug 2022, 12:01 AM
Opanuga Stephen
Opanuga Stephen - avatar
- 1
answer is <> and char.
15th Jan 2020, 9:18 AM
Imanuel Wicaksono
Imanuel Wicaksono - avatar