Say I have an extremely simple Foo class like so:
#include <iostream>
class Foo
{
public:
Foo() {std::cout << "bar" << std::endl;}
};
I have always thought that both Foo foo
and Foo foo()
would output bar
, as they both call the constructor. But when I try:
int main()
{
Foo foo();
return 0;
}
Nothing gets outputted. Is there a reason for this? How can I make sure that the constructor gets called in both instances?