我試圖讓到pow()
功能從文件math.h someihing類似於一個簡單的通話..曖昧POW()函數
#include<math.h>
int main()
{
float v,w;
w=3.0;
v=pow(w,0.5);//i think this is 'float pow(float,float)'
return 0;
}
但Visual Studio中說,這是一個錯誤
1>c:\users\user\documents\visual studio 2008\projects\deo\deo\main.cpp(7) : error C2666: 'pow' : 6 overloads have similar conversions
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(575): could be 'long double pow(long double,int)'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(573): or 'long double pow(long double,long double)'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(527): or 'float pow(float,int)'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(525): or 'float pow(float,float)'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(489): or 'double pow(double,int)'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(123): or 'double pow(double,double)'
1> while trying to match the argument list '(float, double)'
我以爲我的格式爲float pow(float, float)
。
閱讀錯誤消息的最後一行。 0.5被認爲是一個double,並且編譯器無法弄清楚自動重做它的內容,因爲有幾次強制轉換可以工作。 – tloach 2010-06-30 18:43:07
我刪除了'c'標籤,因爲這是'C++'特有的。 – 2010-06-30 18:49:13