Let's say I have a class defined as follows:
class foo{};
now, this is perfectly acceptable;
foo f;
how come this is a compiler error? (uninitialized const ‘f’
)
const foo f;
Why do we have to do this?
const foo f = foo();
I know why we can't do this..
const foo f(); // though it compiles..
Interestingly, the following is valid:
const std::string f;
So what is missing from foo
?
I realize that there are three questions there and it's bad form, but I'm hoping someone can clear this up for me in one answer.
EDIT: please feel free to close it if it's stupid...
See Question&Answers more detail:os