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

  • (A) template <typename T> T myFunction(T a) { }
  • (B) template <class T> T myFunction(T a) { }
  • (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 declare a function template in C++.
Explanation by: Shiva Ram
Both 'template <typename T>' and 'template <class T>' are valid ways to declare a function template in C++.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
134
Total Visits
πŸ“½οΈ
2 y ago
Published
πŸŽ–οΈ
Shiva Ram
Publisher
πŸ“ˆ
89%
Success Rate