Defining an Exception Class to Represent the Type of Problem That Might Occur
Figure 17.1 defines class
DivideByZeroException as a derived class of Standard Library class runtime_error (from header <stdexcept>). Class
runtime_error—a derived class of exception (from header <exception>)—is the C++ standard base class for representing runtime errors. Class
exception is the standard C++ base class for exception in the C++ Standard Library. (Section 17.10 discusses class
exception and its derived classes in detail.) A typical exception class that derives from the
runtime_error class defines only a constructor (e.g., lines 11–12) that passes an error-message string to the base-class
runtime_error constructor. Every exception class that derives directly ...