I was reading Stroustrup's "Programming -- Principles and Practice Using C++" and found that he included a function without the main curly braces without explaining himself and online people say it is impossible.
I have compiled the code and it works totally fine.
void f()
try {}
catch(...) {}
I expect to get a compiler error from this but I do not and it works fine. I am using C++17.
not require curly braces?
There are curly braces:
void f() try {} catch(...) {}
^^
This is a Function-try-block:
A function-try-block associates a sequence of catch clauses with the entire function body
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With