// @topic T53005 12/03/2012 -- Operator Overloading // @brief Rational number demo #include <iostream> #include <iomanip> // for std::boolalpha #include "rational.h" int main () { Rational x( 1, 3 ); Rational y( 5, 8 ); Rational z = x; // copy constructor x = -y; // unary negation and assignment operators //x = y.operator-(); // member operator call x = operator-( y ); // non-member operator call std::cout << x; // overloaded output operator //Equality comparison operator == returns boolean //result comparing two rational numbers: bool result = ( x == -y ); std::cout '\n' << std::boolalpha << result << '\n'; return 0; }