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
- Coordinates copying, assignment, destruction, and ownership transfer in classes that manage resources.
- How deep it goes
- Defines the five operations and demonstrates deep copying, cleanup, and defaulted moves with smart pointers.
- Examples
- Contrasts costly copying with std::move and shows a Page using unique_ptr and defaulted move operations.
- What you can do after
- Apply the rule by adding move construction and assignment alongside copy operations and a destructor for resource transfer.
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.
What to know first
- copy assignment operatorA copy assignment operator is a C++ special member function that copies state from one object into an already existing object of a compatible type.
- copy constructorA copy constructor is a constructor that initializes a new object from an existing object of the same class or type.
- initializerAn initializer is a function, declaration, or language construct that establishes an initial value or state for an object, value, or computation.
Related concepts
- 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.
- moveuses · Move semantics are language rules that transfer a value or its resources to another binding or object without copying them, potentially making the original binding unavailable.
- move constructorhas part · A move constructor is a C++ special member function that initializes a new object by transferring resources from another object.
- special member functionconfigures · A special member function is a C++ member function with compiler-recognized semantics for object initialization, copying, moving, or destruction.
Questions about big five
What is 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.
Which Manning books explain big five?
100 C++ Mistakes and How to Avoid Them and Learn C++ by Example.
What should I know before learning big five?
Manning books that teach big five usually introduce copy assignment operator, copy constructor and initializer first.
What is the difference between big five and big three?
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. 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.
What are the parts of big five?
Big five includes move constructor.
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.

