Cpp Coding Standards/CLSINIT/ObvCopy
Make it obvious, if the class is intended to be copied. Forbid copying otherwise.
There are three possibilities:
- The default copying behaviour as provided by the compiler is correct. In this case it may be useful to provide a comment that explicitely states this.
- The class shall be copied, but the default behaviour is not correct. This is the case, if the class has members (like pointers that administrate heap memory) that do not copy correctly with the default behaviour. In this case implement copy constructor and operator=().
- The class is not intended to be copied. Make this explicit by
- either deriving from boost::noncopyable
- or declaring (but not implementing) copy constructor and operator=() private.
If the class is an abstract base class, it is often not necessary to decide, if derived classes should be copyable. Slicing is not possible, because these classes cannot be instantiated. So in this case nothing has to be done.