N
nan.li.g
I have this simple code below. When I compiled it, I got the following
error. But after I removed the comment marker(//), i.e. explicitly
defined a constructor, it becomes OK.
The compiler should generate a default constructor for me and the
default one shoule be no different than the one I specified. Why do I
have to specify one in this code?
class A
{
public:
//A() { }
};
int main()
{
const A a;
return 0;
}
[nan@athena test]$ g++ test19.cpp
test19.cpp: In function `int main()':
test19.cpp:10: error: uninitialized const `a'
Thank you very much.
error. But after I removed the comment marker(//), i.e. explicitly
defined a constructor, it becomes OK.
The compiler should generate a default constructor for me and the
default one shoule be no different than the one I specified. Why do I
have to specify one in this code?
class A
{
public:
//A() { }
};
int main()
{
const A a;
return 0;
}
[nan@athena test]$ g++ test19.cpp
test19.cpp: In function `int main()':
test19.cpp:10: error: uninitialized const `a'
Thank you very much.