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”), ...
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.
Read now
Unlock full access