// File: fraction.h // // A fraction ADT. Demonstrates operator overloading. #include class Fraction { public: // Constructors // Fraction(int =0, int =1) ; // default = 0/1 // Arithmetic Operators // Fraction operator +(const Fraction& b) const ; // addition Fraction operator -(const Fraction& b) const ; // subtraction Fraction operator *(const Fraction& b) const ; // multiplication Fraction operator /(const Fraction& b) const ; // division Fraction operator -() const ; // unary negation // Binary Relational Operators: // non-zero return value = YES, zero return value = NO // int operator <(const Fraction& b) const ; int operator <=(const Fraction& b) const ; int operator ==(const Fraction& b) const ; int operator >=(const Fraction& b) const ; int operator >(const Fraction& b) const ; // Test functions int is_zero() const ; int is_one() const ; int is_int() const ; // Conversion int floor() const ; int ceiling() const ; // Input/Output void display(ostream& = cout) const ; // show fraction private: int numer ; int denom ; } ; // Iostream << and >> operators overloaded istream& operator >>(istream&, Fraction&) ; ostream& operator <<(ostream&, const Fraction&) ;