Different types of exceptions can be caught.
#include <iostream> using namespace std; void myFunction(int test) { try{ if(test) throw test; else throw "Value is zero"; }catch(int i) { cout << "Caught Exception #: " << i << '\n'; }catch(const char *str) { cout << "Caught a string: "; cout << str << '\n'; } } int main() { cout << "Start\n"; myFunction(1); myFunction(2); myFunction(0); myFunction(3); cout << "End"; return 0; }