Doubt about overloaded functions and return type

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// overloaded function
#include <iostream>
using namespace 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.
You missed the word "only"

1
2
3
4
5
6
7
8
9
int operate (float a, float b)
{
  return (a*b);
}

float operate (float a, float b)
{
  return (a/b);
}
Is not a valid way to overload operate().
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
Topic archived. No new replies allowed.