Iam using visual studio 2010 and iam trying to use pow but it doesn't work it is keeping say >>> 1 IntelliSense: more than one instance of overloaded function "pow" matches the argument list: c:\users\toha\desktop\c++\enter_name\enter_name\enter_name.cpp
and >>> Error 1 error C2668: 'pow' : ambiguous call to overloaded function c:\users\toha\desktop\c++\enter_name\enter_name\enter_name.cpp
my program was as follows
#include <iostream>
#include<conio.h>
#include<cmath>
void main()
{
int z;
z= pow(2,2);
getch ();
}
In C++, the function std::pow() is overloaded for different types.
This means that it has more versions of itself, written differently for different types.
1 2 3 4 5
double pow (double base , double exponent);
float pow (float base , float exponent);
longdouble pow (longdouble base, longdouble exponent);
double pow (double base , int exponent);
longdouble pow (longdouble base, int exponent);
Then the compiler will choose the correct function from the above list of overloaded std::pow() by checking what types you used for the parameters base and exponent.
And this is where the problem is for you.
You are using int parameters. So the compiler does not know which overload it should use.
1 2 3 4 5 6 7 8 9 10
#include <iostream>
#include<conio.h> // care, non-standard library
#include<cmath>
int main() // main() is never void
{
double z;
z = pow(2.0, 2); // double pow (double base , int exponent);
getch(); // care, non-standard function
}