Rule of Three

Created

If a class manages resources, it has a non-trivial destructor.

Rule of 3: If you have to manage how an object is destroyed, you should also manage how it is copied.

  • Technical version: If you have a non-trivial destructor, you should also define a copy constructor and assignment operator.
  • Another perspective: if your class has a non-trivial destructor, you probably don't want shallow copying.


Also consider whether or not you need equality operator (design decision).