Home » Community » Newbie corner » Who is doing the coping? [implicit-copy | deep-copy | pick constructor]
Re: Who is doing the coping? [implicit-copy | deep-copy | pick constructor] [message #38424 is a reply to message #38422] |
Sat, 15 December 2012 09:35   |
|
Hi navi,
navi wrote on Sat, 15 December 2012 05:24 | I concluded that C++ is writing a implicit copy constructor which is doing a member-wise copy of 'myobject' and neither U++ deep copy nor pick is being used. since myobject only has 3 String and String class has operator= overloaded, so implicit copy constructor is able to carryout its member-wise copy. Is this correct?
|
Yes this is correct. The implicit copy instructor in you case would look like myobject::myobject(const myobject& that)
this.a = that.a;
this.b = that.b;
this.c = that.c;
};
So it works for Strings, but if you did similar thing with Vector, it would use pick assignment operator.
Honza
|
|
|
Goto Forum:
Current Time: Sun Aug 24 11:34:08 CEST 2025
Total time taken to generate the page: 0.03947 seconds
|