error: ambiguous call to overloaded function

Hi,
I am trying to use pow function in my program and get the complier error saying: "ambiguous call to overloaded function". Can't figure out what I did wrong.

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main ()
{
int x, y;
double p, q, r;


cout << "Enter a numeric value for x :" << endl;
cin >> x;

cout << "Enter a numeric value for y :" << endl;
cin >> y;

int n;

for (n=0; n < 19; n++);

{
p = pow(2,n);


cout <<p << endl;
}


system ("pause");
return 0;


}
It's the "pow(2,n)" part. It means that there are other versions of the function that take different arguments or different numbers of arguments, and you haven't provided enough information for it to figure out which one you wanted.

EX:

1
2
3
4
5
6
pow(int a, int b, int c = 0);
//and
pow(int a, int b, char c = "", int d = 0);
//defined...wherever

pow(x,y); //<-- would return ambigous call because compiler can't tell which function you want 
Last edited on
First use [code][/code] around your code.

Second, your parameters need to be of type double, long double, or float. Then it will work.

http://www.cplusplus.com/reference/clibrary/cmath/pow.html
Topic archived. No new replies allowed.