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 8c571bc

Browse files
Correct 04-noexcept.cpp
1 parent 56a2a69 commit 8c571bc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎04-functions.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,23 +538,23 @@ The keyword `noexcept` is used to declare that a function is guaranteed to not t
538538
#include <stdexcept>
539539
using namespace std;
540540
541-
int throw_if_zero(int i) noexcept {
541+
void throw_if_zero(int i) {
542542
if (!i) {
543543
throw runtime_error("found a zero");
544544
}
545545
println("throw_if_zero(): {}", i);
546546
}
547547
548548
int main() {
549-
cout << "Entering main()\n";
549+
println("Entering main()");
550550
try {
551551
throw_if_zero(1);
552552
throw_if_zero(0);
553553
}
554-
catch(...) {
555-
println("Caught an exception!");
554+
catch(exception& e) {
555+
println("Caught an exception: {}", e.what());
556556
}
557-
println("Leaving main()\n");
557+
println("Leaving main()");
558558
}
559559
```
560560

0 commit comments

Comments
(0)

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