// @topic T53015 12/03/2012 -- Operator Overloading // @brief class Rational declaration #ifndef _RATIONAL_H_INCLUDED_ #define _RATIONAL_H_INCLUDED_ #include <iostream> // rational.h class Rational { friend std::ostream& operator<<( std::ostream& ostr, Rational const& rat ); friend Rational operator-( Rational const& rat ); int m_n; // numerator int m_d; // denominator public: // Constructors Rational( int num, int denom ); Rational( Rational const& other ); // copy ctr // Member Unary negation, as in: x = -y //Rational operator-() const; // Member binary equality test operator bool operator==( Rational const& other) const; // Assignment overloaded: Rational& operator=( Rational const& other ); }; // Non-member overloaded operator declarations: Rational operator-( Rational const& rat ); std::ostream& operator<<( std::ostream& ostr, Rational const& rat ); #endif //_RATIONAL_H_INCLUDED_