October 1997
Intermediate to advanced
800 pages
20h 48m
English
In Section 7.4 on page 329, we introduced a range integer class (Rint) with overloaded operators. Recall that range integers are built with an initial value, a minimum, and a maximum.
Rint i(5, 1, 10); // value=5, min=1, max=10 i = 8; // OK i = 88; // error
An overloaded assignment operator verifies that a range integer maintains its value within a specified range. Likewise, a constructor verifies that Rint objects have been built properly.
Rint j(5, 10, 1); // error, max > min Rint k(55, 1, 10); // error, initial value not within range
Error handling with Rint is minimal, using one exception class to handle all possible errors (see Listing 7.6 on page 331). An exception hierarchy ...