[問題] 解讀錯誤訊息
先附上程式碼
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int i = 0;
int max = pow(2,4);
int end;
double x[10];
while(i < 10)
{x[i] = (rand()%max) + 1;
x[i] = x[i] / max;
cout << x[i] << endl;
i++;
}
cin >> end;
return 0;
}
主要是在練習產生十個0~1之間的隨機亂數
然而卻產生下列的錯誤訊息:
Error 1 error C2668: 'pow' : ambiguous call to overloaded
function c:\documents and settings\acer\my documents\visual studio
2010\projects\practice\practice\source1.cpp 8 1 Practice
2 IntelliSense: more than one instance of overloaded function "pow" matches
the argument list: c:\documents and settings\acer\my documents\visual studio
2010\projects\practice\practice\source1.cpp 8 12 Practice
不太清楚程式碼哪裡打錯了
有請板上大神幫忙抓蟲
THX~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.250.67.52
→
07/24 22:53, , 1F
07/24 22:53, 1F
→
07/24 22:53, , 2F
07/24 22:53, 2F
→
07/24 22:54, , 3F
07/24 22:54, 3F
→
07/24 22:57, , 4F
07/24 22:57, 4F
→
07/24 23:01, , 5F
07/24 23:01, 5F
→
07/24 23:04, , 6F
07/24 23:04, 6F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章