We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 56a2a69 commit 8c571bcCopy full SHA for 8c571bc
04-functions.md
@@ -538,23 +538,23 @@ The keyword `noexcept` is used to declare that a function is guaranteed to not t
538
#include <stdexcept>
539
using namespace std;
540
541
-int throw_if_zero(int i) noexcept {
+void throw_if_zero(int i) {
542
if (!i) {
543
throw runtime_error("found a zero");
544
}
545
println("throw_if_zero(): {}", i);
546
547
548
int main() {
549
- cout << "Entering main()\n";
+ println("Entering main()");
550
try {
551
throw_if_zero(1);
552
throw_if_zero(0);
553
554
- catch(...) {
555
- println("Caught an exception!");
+ catch(exception& e) {
+ println("Caught an exception: {}", e.what());
556
557
- println("Leaving main()\n");
+ println("Leaving main()");
558
559
```
560
0 commit comments