call of overloaded is ambiguous

I'm getting this error message from my compiler:

call of overloaded `hypot(double&, double&)' is ambiguous
note candidates are: double hypot(double, double)
note void hypot(double&, double&)

obviously the first is an error message and i've assumed the second line is an example of what it is meant to be and the third is what i've actually got but I dont understand why i'm getting this error message. Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void hypot(double &adj, double &opp);

// code ....

              case '4':
                   cout << "To find the hypotenus of triangle abc please give the values of:\n\n";
                   cout << "Side a: ";
                   cin >> adj;
                   cin.get();
                   cout << '\n' << "Side b: ";
                   cin >> opp;
                   cin.get();
                   cout << "\n\n";
                   hypot(adj, opp);
                   restart();

// code...

void hypot(double &adj, double &opp)
{
     cout << "The hypotenuse of this triangle is ";
     cout << sqrt((adj*adj)+(opp*opp));
     adj = opp = 0;
     return;
}


I dont understand why i'm getting this. All my other functions are of return type void, all use have reference parameters, and have arguments of type double. The only thing different is that this is the only one that has two parameters.
I think it likely that your C++ compiler's libraries provide a hypot() function.

Try renaming your function to something like "hypotenuse()" or some such and see if the error persists.

Hope this helps.
Yeah worked great, thanks.
Topic archived. No new replies allowed.