|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
小甲鱼C++快速入门第27集里照抄的函数,用Code Blocks17.12编绎运行
头文件:
#include <iostream>
#include <string>
#include <cmath>
报错的代码段:void Rational::normalize()
{
if( denominator < 0)
{
numerator = -numerator;
denominator = -denominator;
}
int a = abs(numerator);
int b = abs(denominator);
while( b > 0 )
{
int t = a % b;
a = b;
b = t;
}
numerator /=a;
denominator /=a;
}
这个abs报错如下:||=== Build: Debug in 2019-5-15 (compiler: GNU GCC Compiler) ===|
D:\CodeBlocks\2019-5-15\main.cpp||In member function 'void Rational::normalize()':|
D:\CodeBlocks\2019-5-15\main.cpp|42|error: 'abs' was not declared in this scope|
|
|