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.
2 odpowiedzi
+ 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.