error C2668:"pow":对重载函数的调用不明确

语言:C++

运行平台:VS2010 express

 

错误信息:

错误 1 error C2668: “pow”: 对重载函数的调用不明确

2 IntelliSense: 有多个 重载函数 "pow" 实例与参数列表匹配

 

代码:

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int x,y;
	cin>>x;
	cin>>y;
	cout<<pow(x,y)<<endl;
}

 

错误原因:

VS2010中,数学函数的参数检查更为严格

关于pow()有“long double pow(long double,int)”或“float pow(float,int)”或“double pow(double,int)”

 

解决方法:

明确使用哪种数据类型

比如使用:pow((double)x,y)即明确使用double pow(double,int)

posted @ 2018-07-17 17:52  chris_chan1024  阅读(7363)  评论(0编辑  收藏  举报