// $Id$

// Name: Gary T. Leavens
// Section: all

# ifndef Rat_h
# define Rat_h

#include <ostream.h>

template <class Rep>
class Rat : public Rep
{
public:

  Rat(int n, int d) : Rep(n, d) { }

  virtual Rat & add(Rat<Rep> & y) {
    return *new Rat<Rep>(numer() * y.denom()
		   + y.numer() * denom(),
		   denom() * y.denom());
  }

  bool operator == (Rat<Rep> & y) {
    return (numer() * y.denom())
	    == (y.numer() * denom());
  }
};


template <class Rep>
ostream & operator <<(ostream & out, Rat<Rep> & r) {
  out << r.numer() << "/" << r.denom();
  return out;
}

#endif
