当前位置:   article > 正文

c语言有多个重载函数fabs,c ++-对abs(double)的模棱两可的重载调用

有多个重载函数与abs

我有以下C ++代码:

#include

#include // per http://www.cplusplus.com/reference/clibrary/cmath/abs/

// snip ...

if ( (loan_balance < 0) && (abs(loan_balance) > loan_payment) ) {

...

}

和make爆炸:

error: call of overloaded 'abs(double)' is ambiguous

也感兴趣:

/usr/include/stdlib.h:785: note: candidates are: int abs(int)

如何指定编译器需要在cmath.h中调用可以处理浮点数的abs()?

编译器信息(不确定是否重要):

[some_man@some_box ~/some_code]# gcc -v

Using built-in specs.

Target: i386-redhat-linux

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr /share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux

Thread model: posix

gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/104867
推荐阅读
相关标签
  

闽ICP备14008679号