Solve the following question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Solve the following question

Implement a template boolean IsSameClass() that takes class A and B as template parameters. It should compare class A and B and return false when they are different classes and true if they are the same class.

3rd Jun 2018, 6:25 PM
SOUMITRA MANDAL
SOUMITRA MANDAL - avatar
1 Answer
+ 1
Is this code correct? : template <typename T, typename U> struct is_same { static const bool value = false; }; template <typename T> struct is_same<T, T> { static const bool value = true; }; template <class A, class B> bool IsSameClass() { return is_same<A, B>::value; }
3rd Jun 2018, 6:26 PM
SOUMITRA MANDAL
SOUMITRA MANDAL - avatar