Exception Handling

Exception handling in C++ is done using try, catch, and throw.

try {
  throw 20;
} catch (int e) {
  cout << "An exception occurred: " << e;
}

Use throw to raise an exception and catch to handle it gracefully.

← PrevNext →