Semester -    Subject -

Does overloading depends on return type?


Function overloading is possible in C++ and Java but only if the functions must differ from each other by the types and the number of arguments in the argument list. However, functions can not be overloaded if they differ only in the return type. 

The return type of a function has no effect on function overloading, therefore the same function signature with different return type will not be overloaded.

Example: if there are two functions: int sum() and float sum(), these two will generate a compile-time error as function overloading is not possible here.



Share to whatsapp

More Questions from Module 0

How is Ambari different from ZooKeeper?


View

Write a function to calculate the factorial of a number.


View

QUESTION----       Define data structure ? Explain Needs and   classification of data structures.


View

Write an infinite loop using do while condition.


View

Brief about Bus structure. Explain types of Bus structures ? 


View

Write a function to print the sum of all odd numbers from 1 to n.


View