Error: ambiguous call to overloaded function

This error comes up for me sometimes, and I'm still no sure what it means. Could someone please explain it to me? Here's my program:

#include <iostream>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

int main()
{
int a, b, c;

cout<<"Please enter three nonzero integers to be evaluated: "<<endl;
cin>> a >> b >> c ;

cout << ( pow(a,2)+pow(b,2)==pow(c,2) ? "Possible right triangle." : "Not a possible right triangle.") <<endl;

return 0;
}


Error 1 error C2668: 'pow' : ambiguous call to overloaded function

What did I do wrong? Any input is appreciated.
This error means, that there are several functions with the same name, but different arguments and the compiler doesn't know which to use.
for example in <cmath> there is:
1
2
3
4
5
double pow(double base, double exponent);
long double pow(long double base, long double exponent );
float pow(float base, float exponent);
double pow(double base, int exponent);
long double pow( long double base, int exponent);

I think pow((float)a, 2) would work.
Also I believe there is a function powf(float, float) that is not overloaded, so you can use that freely.
UGH @ using pow to square something.

Just square it:

1
2
pow(a,2)+pow(b,2)==pow(c,2)  // bad
(a*a) + (b*b) == (c*c) // good 
Topic archived. No new replies allowed.