I\'m having some problems runnning the following code. I got this: error C2668: \'pow\' : ambiguous call to overloaded function. I\'ve tried to manually cast the arguments t
C++98 provides the following overloaded versions of pow
:
double pow (double base , double exponent);
float pow (float base , float exponent);
long double pow (long double base, long double exponent);
double pow (double base , int exponent);
long double pow (long double base, int exponent);
The first argument you are using, 16
, can be converted to any of the types of the first arguments used in those functions. Hence, the compiler cannot resolve the ambiguity. You can resolve the ambiguity by being explicit with the first argument, by specifying its type. Any one of the following should work:
pow(16.0, strlen(n) - i - 1);
pow(16.0f, strlen(n) - i - 1);
pow(16.0l, strlen(n) - i - 1);
If you are able to use C++11
, you can use your existing code. It has an overload:
double pow (Type1 base , Type2 exponent);
where Type1
and Type2
are arithmetic types.