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

  • (A) template <typename T> void MyClass<T>::myFunction() { }
  • (B) template <class T> void MyClass<T>::myFunction() { }
  • (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 member function outside a class template.
Explanation by: Gopal Sharma
Both 'template <typename T>' and 'template <class T>' are valid ways to define a member function outside a class template.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
224
Total Visits
πŸ“½οΈ
2 y ago
Published
πŸŽ–οΈ
Gopal Sharma
Publisher
πŸ“ˆ
82%
Success Rate