暫無描述

Rational.h 501B

123456789101112131415161718192021222324
  1. #include <iostream>
  2. using namespace std;
  3. class Rational {
  4. private:
  5. int num, den;
  6. public:
  7. Rational();
  8. Rational(int n, int d);
  9. void reduce();
  10. Rational sum(const Rational &b) const;
  11. Rational operator+(const Rational &b) const;
  12. double operator+(double b) const;
  13. Rational operator*(const Rational &b) const;
  14. bool gt(const Rational &b) const;
  15. bool operator>(const Rational &b) const;
  16. void display() const;
  17. double real() const;
  18. };
  19. double operator+(double a, const Rational &b);