Mega Code Archive

 
Categories / C++ / Language
 

Catch int type exception in a function

#include <iostream> using namespace std; void XHandler(int test){    try {       if(test) throw test;    }catch(int i){       cout << "Caught exception #: " << i << endl;    } } int main(void){    cout << "Start: " << endl;    XHandler(1);    XHandler(2);    XHandler(0);    XHandler(3);    cout << "End"; }