這段代碼在gcc 4.6.1和4.8.1中編譯時沒有錯誤(eclipse auto compilation說:候選者是:float pow(float,int)long double pow(long double, int)double pow(double ,int)):爲什麼函數重載不會導致模糊的錯誤? (C++)
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(void) {
const int i = 0, x = 2;
double y = pow(i, x);
y = log(i)/log(x);
cout << y;
return 0;
}
非常感謝。這段代碼在工作中表現了一些不錯的混淆。編譯器可以被信任?
這裏有什麼問題? – catfood
如果有疑問,請相信編譯器並忘記eclipse – djf
您的程序的(中間)目標是什麼,以取悅eclipse或進行編譯? – PlasmaHH