z****e 发帖数: 2024 | 1 #include
#include
#include
using namespace std;
后面用了abs()
error: call of overloaded ‘abs(double)’ is ambiguous
/usr/include/stdlib.h:691: note: candidates are: int abs(int)
没办法,把using namespace std;去掉,然后一个一个的using。编译通过了。
我估计是用了stdlib里边的abs,但是精度太差了。
怎么调用一个take double 的abs() 呢? |
N***m 发帖数: 4460 | 2 fabs()?
【在 z****e 的大作中提到】 : #include : #include : #include : using namespace std; : 后面用了abs() : error: call of overloaded ‘abs(double)’ is ambiguous : /usr/include/stdlib.h:691: note: candidates are: int abs(int) : 没办法,把using namespace std;去掉,然后一个一个的using。编译通过了。 : 我估计是用了stdlib里边的abs,但是精度太差了。 : 怎么调用一个take double 的abs() 呢?
|
z****e 发帖数: 2024 | 3 Thanks!!!
久违的记忆深处,这个函数终于开始闪闪发光。
【在 N***m 的大作中提到】 : fabs()?
|
t****t 发帖数: 6806 | 4 abs(int) is declared in stdlib.h (); while fabs(double) and
additional overloaded abs(double) is declared in math.h ().
if you want abs(int), but include only without , then
compiler won't know how to convert int to double/float/long double.
on the other hand, if you want abs(double) but you include only
without , compiler won't know how to convert double to int/long/long
long.
so make sure you included what you need.
【在 z****e 的大作中提到】 : #include : #include : #include : using namespace std; : 后面用了abs() : error: call of overloaded ‘abs(double)’ is ambiguous : /usr/include/stdlib.h:691: note: candidates are: int abs(int) : 没办法,把using namespace std;去掉,然后一个一个的using。编译通过了。 : 我估计是用了stdlib里边的abs,但是精度太差了。 : 怎么调用一个take double 的abs() 呢?
|
t******s 发帖数: 119 | 5 zan!
long
【在 t****t 的大作中提到】 : abs(int) is declared in stdlib.h (); while fabs(double) and : additional overloaded abs(double) is declared in math.h (). : if you want abs(int), but include only without , then : compiler won't know how to convert int to double/float/long double. : on the other hand, if you want abs(double) but you include only : without , compiler won't know how to convert double to int/long/long : long. : so make sure you included what you need.
|
z****e 发帖数: 2024 | 6 mater shifu: xin ku le.
long
【在 t****t 的大作中提到】 : abs(int) is declared in stdlib.h (); while fabs(double) and : additional overloaded abs(double) is declared in math.h (). : if you want abs(int), but include only without , then : compiler won't know how to convert int to double/float/long double. : on the other hand, if you want abs(double) but you include only : without , compiler won't know how to convert double to int/long/long : long. : so make sure you included what you need.
|