Hi Bo!
On Saturday, February 18, 2017 at 6:27:08 PM UTC-5, Bo Persson wrote:
> On 2017-02-18 23:29, K. Frank wrote:
> > Hello Group!
> >
> > Why doesn't the line flagged with the error compile?
> > ...
> > if ((bool b = false)); // error: expected primary-expression before 'bool'
> ...
> It's a grammar thing.
>
> A primary-expression can inclucde a declaration of a variable, but as
> soon as you add a '(' it is an '(expression)', which cannot declare
> variables.
Thanks. That makes sense (I guess ...)
By the way, I'm speaking from memory here, but is this the
same reason you can use an extra set of parentheses to "fix"
the "most vexing parse" in that the extra set of parentheses
prevents the expression from being parsed as the unwanted
declaration? (I never understood that either.)
> Bo Persson
Best.
K. Frank