CPP Exception Handling

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::exceptionException and parent class of all standard CPP exceptions.
std::logic_failureException that can be detected by reading a code.
std::runtime_errorException that cannot be detected by reading a code.
std::bad_exceptionUnexpected exceptions in a CPP program.
std::bad_castException thrown by dynamic_cast.
std::bad_typeidException thrown by typeid.
std::bad_allocException thrown by new.




Content Protection by DMCA.com
Please Share