class rat { public: // constructors rat ():t(0),b(1) {} rat (int tt):t(tt),b(1) {} rat (int tt,int bb):t(tt),b(bb) {NRM(); } rat (const rat&r):t(r.t),b(r.b) {} // accesser functions int n () const { return t;} int d() const {return b;} // assignments void operator=(const rat&r) {t = r.t; b = r.b;} void operator+=(const rat&); // other operations operator double () const { return t / (double) b;} const rat&operator++() {t += b; return *this; } const rat operator++(int); private: int t; // data areas int b; void NRM (); // operation used internally static int GCD (int,int); }; const rat operator+ (const rat&,const rat&); const rat operator -(const rat&,const rat&); const rat operator*(const rat&,const rat&); const rat operator/(const rat&,const rat&); const rat operator - (const rat&); bool operator < ( const rat&,const rat&); bool operator == (const rat&,const rat&); ostream&operator << (ostream&,const rat&); istream&operator >> (istream&,rat&);