Big five
The rule of five is a C++ guideline that classes managing resources should consider defining a destructor, copy constructor, copy assignment operator, move constructor, and move assignment operator.
100 C++ Mistakes and How to Avoid Them
The rule of five is a C++ class-design pattern in which a class considers defining a destructor, copy constructor, copy assignment operator, move constructor, and move assignment operator together.
- How it is used
- Uses coordinated special members to express ownership, copying, and exclusive transfer in resource-managing classes.
- How deep it goes
- Defines all five members and demonstrates raw-pointer and smart-pointer implementations, stopping short of a complete ownership redesign.
- Examples
- Uses Page and TextSection examples showing destructive copying, deep copying, pointer moves, and unique_ptr-based defaults.
- What you can do after
- Apply the pattern to resource-owning classes and replace unsafe raw-pointer transfers with explicit move operations or smart pointers.
Read how 100 C++ Mistakes and How to Avoid Them explains big five →
Learn C++ by Example
The rule of five is a C++ design guideline that a class managing resources and declaring one relevant special member function should explicitly consider all five copy and move special member functions.
- How it is used
- Guides resource-managing classes when copy and move behavior must remain consistent.
- How deep it goes
- Explains the five operations, compiler suppression of moves, and compile-time inspection, but does not implement resource ownership.
- Examples
- Uses vector push_back and a polymorphic Blob class with static type-trait assertions.
- What you can do after
- Evaluate copy and move support with std::is_* type traits and recognize when implicit moves are unavailable.
Related concepts
- moveuses · Move semantics describe the transfer of a value or its resources to another binding or object rather than duplicating them.
- move constructorhas part · A move constructor is a C++ special member function that initializes a new object by transferring resources from another object.
- big threecontrasts with · The rule of three is a C++ resource-management guideline that a class defining a destructor, copy constructor, or copy assignment operator generally needs all three.
- special member functionconfigures · A special member function is a C++ member function with compiler-recognized semantics for object initialization, copying, moving, or destruction.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

