
MenTaLguY wrote:
I learned recently that writing the copy constructor here isn't actually necessary -- if you don't explicitly provide one the C++ compiler will generate one for you.
Eeeeeeeeeeeeeek!!!
(This is also true of assignment operators)
A corrolary to this is that if you really don't want a class to have a copy constructor or assignment operator, you will have to settle for making the declaration private and leaving out the definition.
( C++ is fun, isn't it? I've been doing this for many years, and I still learn about a new nuance of the language every week. :P )
The one gotcha with copy constructors is that the default does a bitwise copy. Often that's a very dangerous thing, as anything that 'owns' pointers gets duplicates and you get fun things like double-deletes.
The general thing on some larger projects I've been on was to always start with private copy and assignment operator declarations and no bodies. Then add them if really needed, ( with emphasis on 'if really needed').