+ 1
Function overloading
How functions can be distinguished in a program if they are having same name and number of arguments. Can return type be used???
1 Resposta
+ 3
Overloading is applicable only if we have different method signatures.
In this case, combination of unique parameters with same method name.
Therefore we can't have the method with same signatures of different return type as the compiler will have trouble pick the correct implementation.
For example,
✅ OK
double getArea ( int radius )
double getArea ( int width, int height )
❎ NONO
int getRate (double perecentage )
double getRate ( double percentage )