18.12 CLASS EXCEPTION

The above discussion was regarding exception classes defined by us. The modern C++ compilers provide us with whole hierarchy of exception classes. It is worth noting that header file <exception> provides several types and functions related to exception handling, including std::exception, the base class of all exceptions thrown, by the Standard Library.

In Program 18.4 “excep7C.cpp”, we have derived class myException from class “exception”. Since the base class exception has a virtual method char* what(), we have overloaded it. This method is designed to give simple textual information.

However, the exception classes defined by users need not be derived from class exception. In the earlier example (Program 18.4 “excep7c.cpp”), ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.