主要知识点有:构造函数,重载+,-,×,/,==,>,<,>>,<<,= 操作符,友元函数,辗转相除法求最大公约数
vc++ 6.0那个惊天大bug真是太讨厌了
using std::cin;
using std::cout;
using std::endl;
using std::istream;
using std::ostream;
class Rational
{
public:
Rational(int,int);
Rational(int);
Rational();
bool operator =(const Rational&);
friend void change(Rational&);
friend Rational operator +(const Rational&,const Rational&);
friend Rational operator -(const Rational&,const Rational&);
friend Rational operator *(const Rational&,const Rational&);
friend Rational operator /(const Rational&,const Rational&);
friend bool operator ==(Rational&,Rational&);
friend bool operator >=(Rational&,Rational&);
friend bool operator <=(Rational&,Rational&);
friend bool operator >(Rational&,Rational&);
friend bool operator <(Rational&,Rational&);
friend istream

本文介绍了一个使用C++编写的分数类,涵盖了构造函数、重载基本算术和比较操作符,以及利用辗转相除法计算最大公约数。同时提到了在vc++ 6.0中遇到的一个重大bug。
最低0.47元/天 解锁文章
5672

被折叠的 条评论
为什么被折叠?



