class
<exception>
std::exception
Standard exception class
All objects thrown by components of the standard library are derived from this class. Therefore, all standard exceptions can be caught by catching this type by reference.
It is declared as:
|
|
|
|
Member functions
- (constructor)
- Construct exception (public member function)
- operator=
- Copy exception (public member function)
- what (virtual)
- Get string identifying exception (public member function)
- (destructor) (virtual)
- Destroy exception (public virtual member function)
Derived types (scattered throughout different library headers)
- bad_alloc
- Exception thrown on failure allocating memory (class)
- bad_cast
- Exception thrown on failure to dynamic cast (class)
- bad_exception
- Exception thrown by unexpected handler (class)
- bad_function_call
- Exception thrown on bad call (class)
- bad_typeid
- Exception thrown on typeid of null pointer (class)
- bad_weak_ptr
- Bad weak pointer (class)
- ios_base::failure
- Base class for stream exceptions (public member class)
- logic_error
- Logic error exception (class)
- runtime_error
- Runtime error exception (class)
Indirectly (through logic_error):
- domain_error
- Domain error exception (class)
- future_error
- Future error exception (class)
- invalid_argument
- Invalid argument exception (class)
- length_error
- Length error exception (class)
- out_of_range
- Out-of-range exception (class)
Indirectly (through runtime_error):
- overflow_error
- Overflow error exception (class)
- range_error
- Range error exception (class)
- system_error
- System error exception (class)
- underflow_error
- Underflow error exception (class)
Indirectly (through bad_alloc):
- bad_array_new_length
- Exception on bad array length (class)
Indirectly (through system_error, since C++11):
- ios_base::failure
- Base class for stream exceptions (public member class)
Example
|
|
Possible output:
exception caught: St10bad_typeid