Re: Use of copy constructor in pass by value
From: Risto Lankinen (rlankine_at_hotmail.com)
Date: 02/05/04
- Next message: Howie: "Re: c++ wrapper class for zlib ?"
- Previous message: DeMarcus: "Is there any Matrix in the STL?"
- In reply to: Rolf Magnus: "Re: Use of copy constructor in pass by value"
- Next in thread: lilburne: "Re: Use of copy constructor in pass by value"
- Reply: lilburne: "Re: Use of copy constructor in pass by value"
- Reply: Karl Heinz Buchegger: "Re: Use of copy constructor in pass by value"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 05 Feb 2004 13:08:20 GMT
"Rolf Magnus" <ramagnus@t-online.de> wrote in message
news:bvt7vu$9o6$00$1@news.t-online.com...
> madhukar_bm wrote:
>
> > We know that copy constructor is used if a class object is passed by
> > value to a function, is there any logic behind the use of copy
> > constructor as assignment operator could also have been used instead
> > of copy constructor
>
> What would it assign to? You have to create a new object that is a copy
> of an existing one, and that's exactly what the copy constructor is
> for. The assignment operator is for making an existing object a copy of
> another one.
This is in fact an interesting question. If copy constructor is
inaccessible, is the system allowed to default-construct, and
then assign, to simulate the effect of copy construction when
it implicitly needs to? If not, would it make sense to allow it
to happen?
- Risto -
- Next message: Howie: "Re: c++ wrapper class for zlib ?"
- Previous message: DeMarcus: "Is there any Matrix in the STL?"
- In reply to: Rolf Magnus: "Re: Use of copy constructor in pass by value"
- Next in thread: lilburne: "Re: Use of copy constructor in pass by value"
- Reply: lilburne: "Re: Use of copy constructor in pass by value"
- Reply: Karl Heinz Buchegger: "Re: Use of copy constructor in pass by value"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|