On Sun, 20 Apr 2008 18:43:54 +0200, puzzlecracker <>
wrote:
> Why should the copy constructor take a const reference and not just a
> const?
>
> If efficiency is no longer an issue, say size of the object won't
> noticeably degrade performance, is it because we can assign temp
> object only to const reference, and not just const?
>
>
> class string {
> public;
> string();
> operator char *();
> string (const string & )
>
> };
>
>
> Say, we have string s="hello";
>
> wouldn't that work if copy ctor took const?
>
> I just don't see any reasons other than efficiency.
>
> Thanks
Why copy ctor should be allowed to change the element passed at him ?
|