October 2004
Intermediate to advanced
240 pages
6h 22m
English
Copy consciously: Knowingly choose among using the compiler-generated copy constructor and assignment operator, writing your own versions, or explicitly disabling both if copying should not be allowed.
A common mistake (and not only among beginners) is to forget to think about copy and assignment semantics when defining a class. This happens often with small helper classes such as those meant for RAII support (see Item 13).
Ensure that your class provides sensible copying, or none at all. The choices are:
• Explicitly disable both: If copying doesn’t make sense for your type, disable both copy construction and copy assignment by declaring them as private unimplemented functions: