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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.