Exception handling is necessary in an efficient code, as if it is not handled properly, further execution of code stops as soon as any exception occurs. CPP provides numerous ways and features to handle these exceptions in CPP codes, which makes the code more vulnerable to exceptional situations.
Exception can refer to any situation and condition that does not go with the normal flow of the program and thus have a tendency to halt the execution of the program in between. Some of the common exception classes defined in CPP are listed below.
|std::exception||Exception and parent class of all standard CPP exceptions.|
|std::logic_failure||Exception that can be detected by reading a code.|
|std::runtime_error||Exception that cannot be detected by reading a code.|
|std::bad_exception||Unexpected exceptions in a CPP program.|
|std::bad_cast||Exception thrown by dynamic_cast.|
|std::bad_typeid||Exception thrown by typeid.|
|std::bad_alloc||Exception thrown by new.|