Movatterモバイル変換


[0]ホーム

URL:


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

Commit30c2048

Browse files
committed
Updates from pull request#4
1 parent94990bf commit30c2048

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

‎headers/04-noexcept.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
#include<stdexcept>
55
usingnamespacestd;
66

7-
intthrow_if_zero(int i)noexcept {
7+
voidthrow_if_zero(int i)noexcept {
88
if (!i) {
99
throwruntime_error("found a zero");
1010
}
1111
println("throw_if_zero(): {}", i);
1212
}
1313

1414
intmain() {
15-
cout <<"Entering main()\n";
15+
println("Entering main()");
1616
try {
1717
throw_if_zero(1);
1818
throw_if_zero(0);
1919
}
20-
catch(...) {
21-
println("Caught an exception!");
20+
catch(exception& e) {
21+
println("Caught an exception: {}", e.what());
2222
}
23-
println("Leaving main()\n");
23+
println("Leaving main()");
2424
}

‎modules/04-noexcept.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
import std;
44
usingnamespacestd;
55

6-
intthrow_if_zero(int i)noexcept {
6+
voidthrow_if_zero(int i)noexcept {
77
if (!i) {
88
throwruntime_error("found a zero");
99
}
1010
println("throw_if_zero(): {}", i);
1111
}
1212

1313
intmain() {
14-
cout <<"Entering main()\n";
14+
println("Entering main()");
1515
try {
1616
throw_if_zero(1);
1717
throw_if_zero(0);
1818
}
19-
catch(...) {
20-
println("Caught an exception!");
19+
catch(exception& e) {
20+
println("Caught an exception: {}", e.what());
2121
}
22-
println("Leaving main()\n");
22+
println("Leaving main()");
2323
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp