The syntax of a try block (which is a statement in C ++)
try compound-statement handler-sequence
And the if syntax is:
attr(optional) if ( condition ) statement_true attr(optional) if ( condition ) statement_true else statement_false
Where:
statement-true - any statement (often a compound statement) that is executed if the condition evaluates to true
statement-false - any (often a compound statement) that is executed if the condition evaluates to false
So your code is legal code in C++ .
statement_true in your case is a try block.
In law, it looks like:
if (condition) for(...) { ... }
But your code is not very readable and may fall prey to some C ++ pitfalls when adding else . Thus, it is advisable to add an explicit {...} after if in your case.
Mohit Jain Mar 14 '16 at 10:57 2016-03-14 10:57
source share