File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,9 +42,21 @@ catch(const exception& e)
4242 cout << e.what () << endl;
4343}
4444
45+ void case2 () noexcept
46+ {
47+ cout << " noexcept" << endl;
48+ }
49+
50+ void case3 () noexcept
51+ {
52+ throw " Oh My God" ;
53+ }
54+
4555int main ()
4656{
4757 case1 ();
58+ case2 ();
59+ // case3();
4860
4961 cout << " exception demo" << endl;
5062}
Original file line number Diff line number Diff line change 88
99using namespace std ;
1010
11+ void my_square (int x)
12+ {
13+ cout << x*x << endl;
14+ }
15+
1116void case1 ()
17+ {
18+ auto pfunc = &my_square;
19+
20+ (*pfunc)(3 );
21+
22+ auto func = [](int x)
23+ {
24+ cout << x*x << endl;
25+ };
26+
27+ func (3 );
28+ }
29+
30+ void case2 ()
31+ {
32+ int n = 10 ;
33+
34+ auto func = [=](int x)
35+ {
36+ cout << x*n << endl;
37+ };
38+
39+ func (3 );
40+ }
41+
42+ void case3 ()
1243{
1344 auto f1 = [](){};
1445
@@ -43,7 +74,7 @@ class DemoLambda final
4374 }
4475};
4576
46- void case2 ()
77+ void case4 ()
4778{
4879 DemoLambda obj;
4980
@@ -54,6 +85,8 @@ int main()
5485{
5586 case1 ();
5687 case2 ();
88+ case3 ();
89+ case4 ();
5790
5891 cout << " lambda demo" << endl;
5992}
You can’t perform that action at this time.
0 commit comments