Possible Duplicate:
uninitialized const
I understand that a const object needs to initialized.
So for the following code,
class sample
{};
int main()
{
const sample obj;
return 0;
}
the compiler will complain because the const object obj
is not initialized.
But when i modify the code(show below) with a default constructor, the compiler will not throw any error.
class sample
{
public:
sample() { }
};
int main()
{
const sample obj;
return 0;
}
What is the thing that the newly added default ctor does which satisfies the compiler?