Skip to Content
Navigating C++ and Object-Oriented Design
book

Navigating C++ and Object-Oriented Design

by Paul Anderson, Gail Anderson
October 1997
Intermediate to advanced
800 pages
20h 48m
English
Pearson
Content preview from Navigating C++ and Object-Oriented Design

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exploring C++20: The Programmer's Introduction to C++

Exploring C++20: The Programmer's Introduction to C++

Ray Lischner

Publisher Resources

ISBN: 0135327482Purchase book