[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Assignment operator
From: |
Paul Pluzhnikov |
Subject: |
Re: Assignment operator |
Date: |
Fri, 25 Nov 2005 21:53:40 -0800 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) |
Maett <no@spam.pls> writes:
>> What did I wrong?
>>
>
> Write
> *dst = *source;
> Now your operator= should be invoked.
Also note that by convention, op= returns a reference to *this,
allowing constructs like the following:
*dst1 = *dst2 = *src;
CLASS_A& CLASS_A::operator=(const CLASS_A &src)
{
a = src.a;
return *this;
}
Finally, naming the *source* parameter 'dst' (as you did) is at
best very misleading.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.