Skip to content

Commit

Permalink
Correct 04-noexcept.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
cpp-tutor committed Jan 21, 2024
1 parent 56a2a69 commit 8c571bc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions 04-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,23 +538,23 @@ The keyword `noexcept` is used to declare that a function is guaranteed to not t
#include <stdexcept>
using namespace std;
int throw_if_zero(int i) noexcept {
void throw_if_zero(int i) {
if (!i) {
throw runtime_error("found a zero");
}
println("throw_if_zero(): {}", i);
}
int main() {
cout << "Entering main()\n";
println("Entering main()");
try {
throw_if_zero(1);
throw_if_zero(0);
}
catch(...) {
println("Caught an exception!");
catch(exception& e) {
println("Caught an exception: {}", e.what());
}
println("Leaving main()\n");
println("Leaving main()");
}
```

Expand Down

0 comments on commit 8c571bc

Please sign in to comment.