Standard exception classes

The exception class is a simple container for a C string: the string is passed as a constructor parameter and is available through the what accessor. The Standard Library declares the exception class in the <exception> library, and you are encouraged to derive your own exception classes from this. The Standard Library provides the following derived classes; most are defined in <stdexcept>.

Class Thrown
bad_alloc When the new operator has been unable to allocate memory (in <new>)
bad_array_new_length When the new operator has been asked to create an array with an invalid length (in <new>)
bad_cast When dynamic_cast to a reference type fails (in <typeinfo>)
bad_exception An unexpected condition has occurred ...

Get Beginning C++ Programming 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.