Re: Use of copy constructor in pass by value
Date: Thu, 05 Feb 2004 13:08:20 GMT
"Rolf Magnus" <email@example.com> wrote in message
> 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
- Risto -
- Re: Questions of copy constructor
... >> have a copy constructor and assignment operator. ... assignment operator is that a class manages or "owns" some resource. ... Such classes often contain pointers, but the presence of a pointer ... >> itself has a pointer member or not? ...
- Re: Does std::map provides a copy assignment operator?
... assignment and copy constructor. ... > If the compiler-manufactured assignment operator (and also copy ... > destructors if the compiler-generated version does the wrong thing. ... > because the compiler versions will do the right thing for and call the ...
- Re: implementation details
... > to investigating the importance of templates. ... > Retrieve then I'd like to implement some sort of overrun check. ... > an implementation of the assignment operator that'll compare two ... > buffers and a copy constructor that'll do just that. ...
- Re: bitset assignment & copy constructor
... This is part of C++ language specification, not some kind of implementation-specific behavior. ... So whenever I provid a copy constructor or assignment operator in my derived STL class the compiler will take mines, in case I don't the compiler takes the default ones for me correct? ...
- Re: constructor and destructor
... I added a function for assignment operator and a copy ... > constructor and obtained the correct output. ... I had assumed the other way round, that the destructor is ... > Am I not calling the constructor explicitly here? ...