Home / Object Oriented Programming / Define exceptions in C++. Discuss the general exception handling mechanism in C++

Define exceptions in C++. Discuss the general exception handling mechanism in C++

Exception handling in C++ is a process to handle run time errors, we perform exception handling so the normal flow of the application can be maintained even after run time errors.

In C++ exception handling is done by using three keywords.

  • Try: a try block identifies a block of code for which particular exceptions will be activated.
  • Throw: A program throws an exception while a problem shows up. This is done by throw keyword.
  • Catch: It represents a block of code that is executed when a particular exception is thrown.