In C++, the rule of three and the rule of five are general guidelines for creating exception-safe code and formalizing resource management conventions. The guidelines outline how to methodically accomplish these objectives using a class’s default members.
- Constructor (1): Default constructor.
- Constructor (2): Copy constructor.
- Constructor (3): Move constructor.
- Destructor: Destructor is responsible for releasing resources (e.g., memory) allocated by the class.
- Assignment operator (copy assignment): Overloading the assignment operator for copying objects.