Possible Duplicate:
Why is it an error to use an empty set of brackets to call a constructor with no arguments?
I have seen the C++ FQA entries about nested constructor calls and bracing and always wondered how C++ parsers resolve two and why it isn’t possible for parsers to resolve it.
So I get why foo xxx(); is ambiguous. but what makes then foo x(bar()); ambiguous, as it is clearly no forward-declaration. (i.e.: there should be a grammar that can successfully detect this).
Could someone explain the limitations and ambiguity in that part of the C++ grammar?
This could be either:
1) A declaration for a variable called
xwhose value is a default-constructedbar. This is the same asfoo x = bar();.2) A declaration for a function called
xthat returnsfooand takes a single parameter — a function that returns abarand takes no parameters. This is the same asfoo x(bar (void));