我是靠谱客的博主 冷艳跳跳糖,这篇文章主要介绍error C2668: 'sqrt' : ambiguous call to overloaded function,现在分享给大家,希望可以做个参考。
分析:
模棱两可的函数调用,(在oj上提交会编译出错)
- Compile Error
Main.cpp F:temp19889863.2398Main.cpp(21) : error C2668: 'sqrt' : ambiguous call to overloaded function math.h(581): could be 'long double sqrt(long double)' math.h(533): or 'float sqrt(float)' math.h(128): or 'double sqrt(double)' while trying to match the argument list '(int)'
系统分不清该是哪种类型的数据
解决办法:
在sqrt括号里面加强制转换类型,
如:
double Distance(node a,node b)
{
return sqrt((double)(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
最后
以上就是冷艳跳跳糖最近收集整理的关于error C2668: 'sqrt' : ambiguous call to overloaded function的全部内容,更多相关error内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复