FAQ Part 11: Exception Handling

What is exception handling in C++?

Handles runtime errors using:

  • try
  • catch
  • throw
try {
    throw 20;
} catch (int e) {
    cout << "Error: " << e;
}

What can be thrown?

  • Built-in types (e.g. int, string)
  • Custom exception classes