Rational numbers
A rational number can be expressed as a fraction of two integers, called the numerator and denominator.
Rational.h
namespace SmallWindows { class NotaRationalNumber : public exception { public: NotaRationalNumber() {/* Empty. */} };
The default constructor initializes the numerator and denominator to 0 and 1, respectively. The second constructor takes a string and throws a NotaRationalNumber
exception if the string does not hold a valid rational number. The copy constructor and the assignment operator take another rational number. The String
conversion operator returns the rational number as a string:
class Rational { public: Rational(int numerator = 0, int denominator = 1); Rational(const String& text); Rational(const Rational &rational); Rational operator=(const Rational &complex); operator String() const; bool operator==(const Rational &rational) const; bool operator!=(const Rational...