// class rational// rational number data abstraction
// class rational// rational number data abstraction
class rational {public: // constructors rational () : top(0), bottom(1) { } rational (int t) : top(t), bottom(1) { } rational (int t, int b) : top(t), bottom(b) { normalize(); } rational (const rational & r) : top(r.top), bottom(r.bottom) { } // accesser functions int numerator () const { return top; } int denominator () const { return bottom; } // assignments void operator = (const rational & r) {top = r.top; bottom = r.bottom;} void operator += (const rational &); // other operations operator double () const { return top / (double) bottom; } const rational & operator++() { top += bottom; return this; } const rational operator++(int);private: int top; // data areas int bottom; void normalize (); // operation used internally