Your problem is in the instantiation. You don't need Foo d = Foo();
for a default constructor.
Keep your class the same, but try this for instantiation:
Foo d;
In fact, you don't even need Foo d = Foo(arguments);
for constructing with parameters. That should be like this:
Foo d(arguments);