// -------------------------------------------- // frac.h fractions // -------------------------------------------- #ifndef frac_h #define frac_h class frac { private: int n; // numerator int d; // denominator public: frac(int ni= 0, int di = 1); // constructor (auto normalizes) frac(const frac &f); // copy constructor frac &operator=(const frac &f); // assignment operator void normalize(); friend int num(const frac &f); // numerator friend int dnum(const frac &f); // denominator friend double eval(const frac &f); // -> double friend void peval(const frac &f); // print eval friend void pleval(const frac &f); // print eval nl friend frac operator+(const frac &f, const frac &g); friend frac operator*(const frac &f, const frac &g); friend frac operator/(const frac &f, const frac &g); friend int operator>(const frac &f, const frac &g); friend void r(frac &f); // read }; #endif // ------------------------------------------------------------------