I am using Visual C++ 2005 to write code a win32 console application.
There was an error message about the power function when I compiled the code. It is: error c2668: 'pow' :ambiguous call to overloaded function.
The statement is:
tempDistance += pow((data[selectedInstance][k]-data[j][k...
I used various headers like:
%26lt;cmath%26gt;, %26lt;math.h%26gt; %26lt;valarray%26gt; and %26lt;complex%26gt; but the error message remained the same.
What is the cause of the error? I've checked the syntax and it seems correct.
Pow() error in Visual C++ 2005?
double pow(double x,double y) (from math.h); there you also have powf (for float) and powl ofr long double); Check how you declared tempDistance and the array! The compiler doesn't know what conversion to apply in your case...
Reply:What?
Reply:Double check the data type of your argument to the pow() function. There is likely more than one overload of pow() that will do what you want, but the compiler can't decide which one to use. Just stick and explicit cast in there and be done with it. To wit:
pow( double(data[selectedInstance]........
Note the insertion of a double() constructor!
Or use old-fashioned C-style cast:
(double)(arg)
Reply:Here is what I'm finding as the problem, pow(int, int) has been removed from math.h.
1. Look at the data type of your arguments.
2. Look at the data type of your variable. (tempDistance)
The compiler is trying to figure it what to use when it just can't.
if you haven't written overloaded functions yet the error might not make much sense to you.
(Remember that pow(int,int) is gone. )
flash cards
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment