Q. Which of the following is the correct way to define a function with a trailing return type in C++?

  • (A) auto myFunction(int x) -> int { return x * x; }
  • (B) int myFunction(int x) { return x * x; }
  • (C) Both A and B
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (C) Both A and B
Explanation: Both options are valid ways to define a function with a trailing return type in C++.
Explanation by: Praveen Singh
Both options are valid ways to define a function with a trailing return type in C++.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
187
Total Visits
πŸ“½οΈ
2 y ago
Published
πŸŽ–οΈ
Praveen Singh
Publisher
πŸ“ˆ
98%
Success Rate