saving . . . saved return type has been deleted. return type has been hidden .
return type
Title
Question
During function overloading ,
Why the return type of the functions(that are overloaded) must be same?

in other books we had read that
overloading functions should have
1) same name(functions should exist in same class)
2)either the parameter type should be different  or the no. of parameters should be different .

NOTHING ABOUT FUNCTIONS  RETURN TYPE.

Advanced-Cpp Function-Overloading-And-Overriding 07-08 min 0-10 sec 20-03-14, 7:34 p.m. vikas_kumar

Answers:

In the tutorial it is mentioned that the return type is same in function overriding,
and not function overloading.
21-03-14, 2:23 a.m. pratham920
14-07-25, 1:56 p.m. 240181601025@crescent.education

Login to add comment


Hi,

Kindly go through the tutorial again.
It is mentioned that, in function overloading the arguments and the data-type of the arguments will be different.
And in function overriding the return-type is same.
21-03-14, 11:56 a.m. Ashwini
14-07-25, 1:57 p.m. 240181601025@crescent.education

Login to add comment



In the tutorial, it is explained that in function overloading, the functions can have different return types, but they must differ in the number or types of arguments.
The return type alone doesn’t help the compiler distinguish overloaded functions.

In function overriding, the return type must generally be the same (or covariant).


14-07-25, 12:54 p.m. 240181601063@crescent.education
14-07-25, 1:57 p.m. 240181601025@crescent.education

Login to add comment


Log-in to answer to this question.