0

Overload different number of argument?

Suppose I define function Add to add 2 integer. int Add(int a, int){ return a+b; }; Then I overload function Add to add to double numbers a and b which is ITS arguments: double Add(double a, double b){ return a+b;}; We can see the number of arguments passed to bot version of function Add are still same, but the return type of both function is different. Please someone explain to me.

14th May 2024, 4:19 AM
Oliver Pasaribu
1 Answer
+ 1
You don't tag any language. Properly tag a language! By the way, function overloading allows you to have multiple functions with the same name but different parameter lists. The compiler distinguishes these functions by their parameter types and number of parameters, not by their return type.
14th May 2024, 4:24 AM
`ᴴᵗᵗየ
`ᴴᵗᵗየ - avatar