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

Enter 3 numbers from the user & make a function to print their average.


View

Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered. 


View

Write a function which takes in 2 numbers and returns the greater of those two.


View
Define objects in a graphical system.
View

How ZooKeeper in Hadoop Works?


View
How to use database in Golang?
View
Construct Decision trees to represent the following Boolean functions, (i) A and B (ii) A or [B and C]
View