【发布时间】:2013-06-23 20:05:12
【问题描述】:
此代码在 gcc 4.6.1 和 4.8.1 中编译没有错误(eclipse 自动编译说:候选者是:float pow(float, int) long double pow(long double, int) 双 pow(double, int) ):
#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;
}
非常感谢。这段代码在工作中做了一些很好的混淆。编译器可信吗?
【问题讨论】:
-
这里有什么问题?
-
如有疑问,请相信编译器并忘记 eclipse
-
你的程序的(中间)目标是什么,取悦eclipse,还是被编译?
-
这个程序的目标是理解隐式转换。当然,这只是对具体问题的荒谬简化。我发现发布数千行代码有点夸张。问题是:为什么要编译这段代码?
标签: c++ function overloading implicit-conversion