-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuw.cpp
More file actions
42 lines (37 loc) · 672 Bytes
/
Copy pathsuw.cpp
File metadata and controls
42 lines (37 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// CPP Program to demonstrate Stack Unwinding
#include <iostream>
using namespace std;
// A sample function f1() that throws an int exception
void f1() throw(int)
{
cout << "\n f1() Start ";
throw 100;
cout << "\n f1() End ";
}
// Another sample function f2() that calls f1()
void f2() throw(int)
{
cout << "\n f2() Start ";
f1();
cout << "\n f2() End ";
}
// Another sample function f3() that calls f2() and handles
// exception thrown by f1()
void f3()
{
cout << "\n f3() Start ";
try {
f2();
}
catch (int i) {
cout << "\n Caught Exception: " << i;
}
cout << "\n f3() End";
}
// Driver Code
int main()
{
f3();
getchar();
return 0;
}