Q. Which of the following is the correct way to define a class template in C++?

  • (A) template <typename T> class MyClass { };
  • (B) template <class T> class MyClass { };
  • (C) Both A and B
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (C) Both A and B
Explanation: Both 'template <typename T>' and 'template <class T>' are valid ways to define a class template in C++.
Explanation by: Priyanka Tomar
Both 'template <typename T>' and 'template <class T>' are valid ways to define a class template in C++.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
139
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Priyanka Tomar
Publisher
πŸ“ˆ
81%
Success Rate