// Definition of a rational number class; a rational number object 
// will be a fraction, with a numerator and a non-zero denominator.
// Throughout, any operation which results in a denominator being zero
// generates an error.

// A class is a type (or abstract data type), with both data and operations

class Rational
{  /* the following extends the standard arthmetic operator + to rationals */
  friend Rational operator+ (Rational r1, Rational r2);

  /* Overload familiar I/O operations */
  friend istream& operator>> (istream& istr, Rational& r);
  friend ostream& operator<< (ostream& ostr, Rational r);


public:  /* this presents the user's view of rational numbers */

  /* Constructor */
  Rational (int num = 0, int denom = 1);  /* the rational number num/denom */
  /* if no parameters are given, use 0/1
     if the second parameter is omitted, use num/1 */

  /* Return rational number as a decimal */
  double eval (void);

private:  /* the following details are for implementation only and 
             are not accessible by users */
  int numerator;
  int denominator;
  int gcd (int a, int b);  /* function to find the greatest common divisor */
};
