September 2016
Intermediate to advanced
588 pages
12h 22m
English
This Appendix defines the Rational and Complex classes from the Converters section in the previous chapter.
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 ...
Read now
Unlock full access