Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0d9b390

Browse files
All about catch
1 parent f00be79 commit 0d9b390

File tree

1 file changed

+48
-0
lines changed
  • Learn_CPP_Programming_Deep_Dive/Section 17 Exception_Handling/All_about_catch

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
class MyException
6+
{
7+
8+
};
9+
10+
class MyException2 : public MyException
11+
{
12+
13+
};
14+
15+
16+
int main(void)
17+
{
18+
try
19+
{
20+
throw MyException();
21+
}
22+
catch(int e )
23+
{
24+
cout<<"Int catch here"<<endl;
25+
}
26+
catch(float e)
27+
{
28+
cout<<"Float catch here"<<endl;
29+
}
30+
catch(char e)
31+
{
32+
cout<<"Character catch here"<<endl;
33+
}
34+
catch(MyException2 e)
35+
{
36+
cout<<"MyException2 catch here"<<endl;
37+
}
38+
catch(MyException e)
39+
{
40+
cout<<"MyException catch here"<<endl;
41+
}
42+
catch(...) // ... -> is called ellipsis
43+
{
44+
cout<<"Catch all here"<<endl;
45+
}
46+
47+
cout<<"End of program";
48+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /