Can two overloaded functions differ only by their return type in C++?

  • It depends on the C++ compiler being used.
  • No, C++ does not allow overloading based on return types.
  • Only in C++14 and later versions.
  • Yes, C++ allows overloading based on return types.
Yes, C++ allows overloaded functions to differ in return type. However, this alone isn't sufficient to distinguish between them; overloads must also differ in their parameter lists. This feature is known as "ad-hoc" polymorphism or function overloading.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *