在一個程序上工作,並且有一行代碼給我提出了問題。我不知道是否有人在這裏可以知道如何解決的這一行代碼:模糊呼叫超載 - 鑄造
long long x;
srand(time(NULL));
x = rand() % 1000;
long long range = pow (2, 60*(pow(2,x)-1)) ;
每當我運行此我得到一個錯誤,指出有一個模糊的通話超載。 我做了一些研究,似乎與不同類型(關於long long
)有關。我想可能有辦法以不同的方式來解決這個問題,但我不確定如何做到這一點。 爲了讓第二行代碼正常工作,任何人都會碰巧有什麼建議嗎?
編輯:我收到以下錯誤:
main1.cpp:149: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
/usr/include/architecture/i386/math.h:343: note: candidate 1: double pow(double, double)
/usr/include/c++/4.2.1/cmath:357: note: candidate 2: float std::pow(float, float)
main1.cpp:149: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
/usr/include/architecture/i386/math.h:343: note: candidate 1: double pow(double, double)
/usr/include/c++/4.2.1/cmath:357: note: candidate 2: float std::pow(float, float)
隨着該Luchian建議,出現以下錯誤的方法如下:
main1.cpp:149: error: call of overloaded 'pow(int, long long int&)' is ambiguous
/usr/include/architecture/i386/math.h:343: note: candidates are: double pow(double, double)
/usr/include/c++/4.2.1/cmath:357: note: float std::pow(float, float)
/usr/include/c++/4.2.1/cmath:361: note: long double std::pow(long double, long double)
/usr/include/c++/4.2.1/cmath:365: note: double std::pow(double, int)
/usr/include/c++/4.2.1/cmath:369: note: float std::pow(float, int)
/usr/include/c++/4.2.1/cmath:373: note: long double std::pow(long double, int)
什麼是錯誤? http://ideone.com/GO1cT –
每當我運行這個我得到「錯誤:重載調用」pow(int,long long int&)'不明確「 – Valrok
編輯您的問題以包含** full **錯誤消息 - 包括候選人。 –