17.7. Exceptions and Inheritance
Various exception classes can be derived from a common base class, as we discussed in Section 17.2, when we created class
DivideByZeroException as a derived class of class
exception. If a
catch handler catches a reference to an exception object of a base-class type, it also can
catch a reference to all objects of classes publicly derived from that base class—this allows for polymorphic processing of related exceptions.
Error-Prevention Tip 17.8
Using inheritance with exceptions enables an exception handler to catch related errors with concise notation. One approach is to catch each type of reference to a derived-class ...