为什么sqrt()在智能感知中使用两个pow()的内部计算是错误的
How come sqrt() with which uses a calculation of two pow()'s inside of is wrong in intellisense
我有这样的代码:
int findY ( int x, int r) {
return sqrt(pow(x,2) - pow(r,2));
};
但由于某种原因,智能感知女士将其标记为错误的语法。我不知道为什么。
看看它给出的错误:
1>..main.cpp(7): error C2668: 'pow' : ambiguous call to overloaded function
1> C:Program Files (x86)Microsoft Visual Studio 10.0VCincludemath.h(583): could be 'long double pow(long double,int)'
1> C:Program Files (x86)Microsoft Visual Studio 10.0VCincludemath.h(535): or 'float pow(float,int)'
1> C:Program Files (x86)Microsoft Visual Studio 10.0VCincludemath.h(497): or 'double pow(double,int)'
1> while trying to match the argument list '(int, int)'
基本上,它是一个模糊的重载。所以你需要强制转换它来澄清:
return sqrt(pow((double)x,2.) - pow(((double)r,2.));
不仅如此,您真的打算将返回类型设置为整型吗?
相关文章:
- 如何在C++中从两个单独的for循环中添加两个数组
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 当在同一名称空间中有两个具有相同签名的函数时,会发生什么
- 如何返回一个类的两个对象相加的结果
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 两个字符串在 c++ 中不相等
- 在两个类中共享相同的函数调用,并在不需要时避免空实例化
- 两个文件使用彼此的功能-如何解决
- 为什么Mat类的两个对象可以在不重载运算符+的情况下添加
- 如何确保在使用基于布尔值的两个方法之一调用方法时避免分支预测错误
- 停止cmake target_link_libraries将插件中静态库的两个对象文件链接到静态库本身
- 将fold表达式与std::一起用于两个元组
- 如何在C++中比较两个char数组
- 给定两个偶数,求出它们之间所有偶数的平方和
- 比较两个大小不等的映射c++
- C++需要帮助从用户那里获得一个整数,并确保它在另外两个整数之间
- boost::multiprecision::pow,具有两个cpp_int值
- 带有两个常量的C++:pow()优化
- 为什么sqrt()在智能感知中使用两个pow()的内部计算是错误的