Foo bar();
That is a function declaration.
The 'bar' is a function that takes no parameters and returns a value that has type 'Foo'.
This is often referred to as "C++'s most vexing parse".
C++11 did introduce brace initialization syntax. That is more uniform and easily distinguishable from function declaration.
Got it, I just read up about it and it seems like there are several methods to make it explicit that I'm defining a variable as opposed to a function.
1. Extra parentheses
2. Brace initialization
3. Copy initialization
Is any of them preferred? I hear the word "Copy" and I get scared.
Also, for my second question, is Foo() in isolation simply returning an instance of Foo default constructed?
Last edited on