Let\'s say I have a class defined as follows:
class foo{};
now, this is perfectly acceptable;
foo f;
how
I think there are more alternatives. You can do
const foo f={};
or
const foo f(());
Const means you can not assign to it later, so you have to initialize it. Since you did not define default constructor the compiler assumes it has to be initialized by you. std::string has default constructor so it is called implicitly by compiler.