Skip to content

C++ Idiom: Rule of Three

The rule of three idiom says that if a class needs any of:

  • copy constructor
  • assignment operator
  • destructor

Then it probably need all of them.

The reason for this is that if any of the above is needed then the class likely manages its own resource (allocation/deletion) and this is likely to be needed for all of the actions.

Posted in C/C++, idioms. Tagged with , , , , , .