c++ 错误 |
#include < math.h> (http://power.itp.ac.cn/~ssbao/index/home/diary/2006/915-2.htm) |
在VC6.0中计算表达式log(1/4)/log(2),运行结果为-1.#INF;计算表达式log(4)/log(2),能得到正确结果。
在VS中计算上述两个表达式,均得不到结果,出现了如下一些编译错误:
1>e:/vc/example/projects/helloworld1/helloworld1/对数.cpp(7) : error C2668: “log”: 对重载函数的调用不明确
1> d:/program files/microsoft visual studio 8/vc/include/math.h(567): 可能是“long double log(long double)”
1> d:/program files/microsoft visual studio 8/vc/include/math.h(519): 或“float log(float)”
1> d:/program files/microsoft visual studio 8/vc/include/math.h(121): 或“double log(double)”
1> 试图匹配参数列表“(int)”时
1>e:/vc/example/projects/helloworld1/helloworld1/对数.cpp(7) : error C2668: “log”: 对重载函数的调用不明确
1> d:/program files/microsoft visual studio 8/vc/include/math.h(567): 可能是“long double log(long double)”
1> d:/program files/microsoft visual studio 8/vc/include/math.h(519): 或“float log(float)”
1> d:/program files/microsoft visual studio 8/vc/include/math.h(121): 或“double log(double)”
1> 试图匹配参数列表“(int)”时
看了这些错误,心里一片茫然,因为错误都出现在<math.h>中,我以为vs没装好。
真想去撞死啊~~仔细想想,这显然提示的是类型不匹配。
改为log(4.0/2.0)就OK,其余类似。