Rex Chou wrote:
It is very simple, but the G++ compiler say it's wrong. I don't know
why.
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
cout << pow(2,3) << endl;
return 0;
}
The G++ display: call of overloaded 'pow(int, int)' is ambiguous.
It actually says:
test.cpp: In function 'int main()':
test.cpp:7: error: call of overloaded 'pow(int, int)' is ambiguous
/usr/include/bits/mathcalls.h:154: note: candidates are: double
pow(double, double)
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../include/c++/4.0.3/cmath:360:
note: long double std::pow(long double, int)
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../include/c++/4.0.3/cmath:356:
note: float std::pow(float, int)
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../include/c++/4.0.3/cmath:352:
note: double std::pow(double, int)
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../include/c++/4.0.3/cmath:348:
note: long double std::pow(long double, long double)
/usr/lib/gcc/x86_64-linux-gnu/4.0.3/../../../../include/c++/4.0.3/cmath:344:
note: float std::pow(float, float)
Just choose on of the appropriate functions ant tell the compiler by
casting or typing appropriate dot.zero's ('.0') which function to choose.