class rational { public: // constructors rational (); // default constructor rational (int i); // constructs the rational i/1 rational (int i, int j); // constructs the rational i/j rational (const rational &); // copy constructor // accessor functions int numerator () const; int denominator () const; // assignments void operator = (const rational &); void operator += (const rational &); void operator -= (const rational &); void operator *= (const rational &); void operator /= (const rational &); // comparison // when called as p.compare(q), this function returns 1 if p > q, 0 if p = q, and -1 if p < q int compare (const rational &) const; private: // data areas int top; int bottom; // This operation is used internally. // normalize() reduces the numerator and the denominator of the rational to smallest // possible values. For example, normalize() will reduce 200/450 to 4/9. To do this // normalize() will have to compute the greatest common divisor (gcd) of the numerator // and the denominator and then divide. // normalize() is used after every arithmetic operation involving rationals to ensure // that the numerator and the denminator do not become too large. void normalize (); };