Foo foo2();
change to
Foo foo2;
You get the error because compiler thinks of
Foo foo2()
as of function declaration with name ‘foo2’ and the return type ‘Foo’.
But in that case If we change to Foo foo2
, the compiler might show the error " call of overloaded ‘Foo()’ is ambiguous"
.