+ 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 Respuesta
+ 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