From: Giovanni Dicanio on
"Frank" <jerk(a)gmx.de> ha scritto nel messaggio
news:98d7f241-37f7-4d59-b6f9-40956bb9716c(a)24g2000yqy.googlegroups.com...

> I see... so the copy constructor of C1 won't invoke
> the assignment operators of its members to initialize
> them like I thought?

Doug was very clear in his post: the copy constructor of C1 will just invoke
the *copy constructors* (not operator=) of its data members.

Giovanni


From: Frank on
Giovanni Dicanio wrote:

> Doug was very clear in his post: the copy constructor of C1 will just invoke
> the *copy constructors* (not operator=) of its data members.

Ok... so the question remains: Why doesn't C1 have a
copy constructor anymore from the moment I wrote one
for one of its members?
From: Goran on
On May 11, 10:59 am, Frank <j...(a)gmx.de> wrote:
> Giovanni Dicanio wrote:
> > Doug was very clear in his post: the copy constructor of C1 will just invoke
> > the *copy constructors* (not operator=) of its data members.
>
> Ok... so the question remains: Why doesn't C1 have a
> copy constructor anymore from the moment I wrote one
> for one of its members?

Perhaps you should show the code that exhibits the behavior. Also, you
should try to compile it with e.g. comeau online.

Goran.
From: Frank on
Goran wrote:

> On May 11, 10:59 am, Frank <j...(a)gmx.de> wrote:
>
> > Giovanni Dicanio wrote:
> > > Doug was very clear in his post: the copy constructor of C1 will just invoke
> > > the *copy constructors* (not operator=) of its data members.
>
> > Ok... so the question remains: Why doesn't C1 have a
> > copy constructor anymore from the moment I wrote one
> > for one of its members?
>
> Perhaps you should show the code that exhibits the behavior. Also, you
> should try to compile it with e.g. comeau online.

Yes, thanks, I'll strip it down a bit because I found a
solution now but don't understand it - it works if I
make the parameter of the copy constructor of C2
a "const":

This works:

class C2
{
...

C2(const C2 &cRHS)
{
AssignData(cRHS);
}
}

This doesn't work:

class C2
{
...

C2(C2 &cRHS)
{
AssignData(cRHS);
}
}
From: Giovanni Dicanio on
"Frank" <jerk(a)gmx.de> wrote:


> This works:
>
> class C2
> {
> ...
>
> C2(const C2 &cRHS)

> This doesn't work:
>
> class C2
> {
> ...
>
> C2(C2 &cRHS)

I think this is because the usual pattern for copy ctor for class X is:

X::X( const X & )


Giovanni