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 ... |