I am trying to use pow(2,a); and I am getting a error 'pow' ambigous call to over load function. I don't understand why, I added the cmath libarary. Here is the code.

#include <iostream>
#include <cmath>
using namespace std;
int binaryToDec(int);
int main() 
{
 
binaryToDec(1110);

return 0;
}
int binaryToDec(int n) 
{
    int a=0;
    int numTotal=0;
    if(n%10 == 0){
        a++;
        numTotal+=0;
    }
    else if(n%10!=0)
         a++;
        numTotal+=pow(2,a); //here is where I get the error
 
binaryToDec(n / 10);
cout<<numTotal<<endl;
return numTotal;
}

any help would be great

Ignore this one, I realized I need to use a double instead on an int

I am trying to use pow(2,a); and I am getting a error 'pow' ambigous call to over load function. I don't understand why, I added the cmath libarary. Here is the code.

#include <iostream>
#include <cmath>
using namespace std;
int binaryToDec(int);
int main() 
{
 
binaryToDec(1110);

return 0;
}
int binaryToDec(int n) 
{
    int a=0;
    int numTotal=0;
    if(n%10 == 0){
        a++;
        numTotal+=0;
    }
    else if(n%10!=0)
         a++;
        numTotal+=pow(2,a); //here is where I get the error
 
binaryToDec(n / 10);
cout<<numTotal<<endl;
return numTotal;
}

any help would be great

This question has already been answered. Start a new discussion instead.