This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9740: Object included in another is not initialized properly
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, tron at eng dot tau dot ac dot il
- Date: 19 Feb 2003 02:42:58 -0000
- Subject: Re: c++/9740: Object included in another is not initialized properly
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, tron at eng dot tau dot ac dot il, gcc-gnats at gcc dot gnu dot org
Synopsis: Object included in another is not initialized properly
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Wed Feb 19 02:42:58 2003
State-Changed-Why:
Reading a good book about C++ might help.
What you do here
class A {
int i;
int p;
public:
==> A() {A(0); };
A(int j) {i=j; p=0; cout << "in A constuctor:\np=" << p << endl;};
int getp() { return p; };
};
is not redirecting from one constructor to another, but
you create an unnamed, temporary object and call its
conversion constructor. The object you're presently in
in the first constructor is not change, and is left
uninitialized.
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9740