I'm reading the documentation on this site, wich is absolutely useful, but there's a line that makes no sense to me:
Notice that a function cannot be overloaded only by its return type. At least one of its parameters must have a different type.
what does this mean?
consider that in the example right above, wich was
// overloaded function
#include <iostream>
usingnamespace std;
int operate (int a, int b)
{
return (a*b);
}
float operate (float a, float b)
{
return (a/b);
}
int main ()
{
int x=5,y=2;
float n=5.0,m=2.0;
cout << operate (x,y);
cout << "\n";
cout << operate (n,m);
cout << "\n";
return 0;
}
the "float" oprate requres float numbers and returns a float, while the int operate requres ints ant it returns an int, so they're both being overloaded by their return type.
aaahhh... ok, got it
i thought it was like "At least one of its parameters must have a different type (from the return type)"
Instead it's "At least one of its parameters must have a different type (from the ones of the function with the same name)"
Thank you very much