Hello.
Based on this simple test program:
class Test {};
int main()
{
Test t;
const Test u;
}
Why does the definition of 'u' fail? What if all that's wanted is to
have a default constructed Test object? Must one explicitly write so? E.g.:
const Test u = Test();
What's the rationale for such restriction? And, lastly, why does
defining a default constructor solve the issue? I.e.:
class Test
{
public:
Test() {}
};
int main()
{
Test t;
const Test u;
}
Now the compiler accepts it just fine. Why? Pardon me if the answer to
these questions should be obvious. I don't presently find them to be so.
Thank you,
--
Ney André de Mello Zunino