In our company's coding standard, we have been told to "be aware of the ways (accidental) copying can be prevented".
I am not really sure what this means, but assume that they mean we should stop classes from being copied if this is not required.
What I can think of is as follows:
- Make the copy constructor of a class private.
- Make the assignment operator (operator=) of a class private.
- Make the constructor of a class explicit (to stop classes from being created using incorrect variables).
- For all classes that carry out memory allocation and where copying is required, make sure that the copy constructor and assignment operator carry out deep copying rather than shallow copying.
Am I on the right track? Is there anything I might have missed out?