could anyone help me???

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);
long double pow (long double base, long double exponent);
     double pow (double base     , int exponent);
long double pow (long double base, int exponent);

http://www.cplusplus.com/reference/cmath/pow/

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
}
Thanks A lot....
Topic archived. No new replies allowed.