Exception Handling Flashcards
What is exception
Exception is an unexpected problem that arises during the execution of a program
C++ exception handling is built upon three keywords. What are they?
try, throw and catch
What is the try statement
This allows you to test a block of code for errors while it is being executed
What is the throw statements?
Throw keyword throws an exception when a problem is detected. This enables us to detect custom error.
What is catch statement
This allows you to define a block of code to be executed if an error occurs in the try block
Mention some C++ standard exceptions
bad_cast:
runtime_error:
bad_exceptions
bad_typeid
logic_error
invalid_arguments
length_error
overflow_error
range_error
underflow_error
Differnce between runtime_error and logic_error
Runtime error is An exception that theoretically cannot be detected by reading the code
Logic error is an exception that theoretically can be detected by reading the code.
Describe bad_exceptions
This is a useful device to handle unexpected exceptions in a c++ programs.
Difference between overflow_error and underflow_error
overflow error is thrown if a mathematical overflow occurs
underflow error is thrown if a mathmatical underflow occurs