Mega Code Archive

 
Categories / C++ / Language
 

Throwing Exceptions out of nested function calls

#include <iostream> using namespace std; void foo() {    int  i, j;    i = 14;    j = 15;    throw i; } void call_foo() {    int  k;    k  = 12;    foo(); } int main() {    try {       call_foo();     }    catch(int n) { cout << "\ncaught it " << n << endl; } }