English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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]),2);

I used various headers like:

, and but the error message remained the same.

What is the cause of the error? I've checked the syntax and it seems correct.

2006-07-19 06:49:49 · 5 answers · asked by ZhiYi 1 in Computers & Internet Programming & Design

5 answers

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...

2006-07-19 07:01:47 · answer #1 · answered by agent-X 6 · 0 0

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)

2006-07-19 06:57:01 · answer #2 · answered by sideshot72 3 · 0 0

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. )

2006-07-19 06:58:23 · answer #3 · answered by Alyssa 5 · 0 0

does it say what line the mistakes is on? what are you attempting to do? output all those stars? thats trouble-free. yet idk abotu stdafx.h ive under no circumstances used that part of your code. and for my section i favor no longer to apply the "<> instead of cout<< or think about only a million < instead of two. that could favor to cover all of your blunders.

2016-10-14 23:17:26 · answer #4 · answered by ? 4 · 0 0

What?

2006-07-19 06:51:47 · answer #5 · answered by Katie Wady 2 · 0 0

fedest.com, questions and answers