Why Does try ... catch Blocks Require Braces?
- by Bidou
Hello.
While in other statements like if ... else you can avoid braces if there is only one instruction in a block, you cannot do that with try ... catch blocks: the compiler doesn't buy it. For instance:
try
do_something_risky();
catch (...)
std::cerr << "Blast!" << std::endl;
With the code above, g++ simply says it expects a '{' before do_something_risky(). Why this difference of behavior between try ... catch and, say, if ... else ?
Thanks!