error: ambiguous call to overloaded function

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.


pow(int a, int b, int c = 0);
pow(int a, int b, char c = "", int d = 0);

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.
Topic archived. No new replies allowed.