C++ has a rule that if a statement can be interpreted as a function declaration, it is interpreted in this way.
Hence the syntax Foo f3();
actually declares a function which takes no arguments and returns Foo
. Work this around by writing Foo f3;
, it will call the default constructor too (if there is one, of course).