Copy constructors and operator=()
I have been reading many texts on these two components of an object, but I am not 100% convinced I understand them.
But this is what I think I have:
1) A copy constructor is provided by default, but should be overided in the case you require "deep" copying of your objects data members (i.e. you have allocated memory to pointers and you want the values copied not the pointer).
2) If you provide your own copy constructor you should also provide your own operator= method.
I presume that the reason for 2 is that if you have to "deep" copy with the copy constructor, then the same holds true for any assignment...
I think I have this around the wrong way.. If I define a operator=(), THEN I must have a copy constructor..
But I am not sure I fully understand the purpose of 2. Can anyone enlighten me or correct me? :)