O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.8. Putting It All Together

A RintError Exception Hierarchy

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required