-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path86.cpp
More file actions
36 lines (33 loc) · 673 Bytes
/
Copy path86.cpp
File metadata and controls
36 lines (33 loc) · 673 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
#include<iostream>
using namespace std;
void myFunc(int i)
{
//localized try-catch block in a function
try
{
cout<<"Inside myfunc : "<<i<<endl;
if(i)
throw i;
}
catch(int e)
{
cout<<"Exception is handled locally : "<<e<<endl;
}
}
int main()
{
//try block
try
{
//calling myFunc
myFunc(76);
myFunc(34);
myFunc(23);
//these exception is handled locally inside the myFunc function and exception do not reaches the main() function
}
catch(int i)
{
cout<<"Inside catch block which is in the main() function"<<endl;
}
return 0;
}