liveBook · Manning

Big three

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.

How 3 Manning books explain it

Object-Oriented Software Design in C++

A C++ class-design rule grouping the destructor, copy constructor, and copy assignment operator as special members that may need coordinated implementation.

How it is used
Uses coordinated special-member implementation to control copying and destruction while diagnosing hidden vector operations.
How deep it goes
Defines the rule and demonstrates member-wise copying, assignment, self-assignment protection, and logged runtime calls.
Examples
Uses an instrumented Date class, an Appointments vector, append and insertion operations, and constructor or destructor logs.
What you can do after
Diagnose/debug with instrumentation by identifying implicit copies, assignments, destructions, allocations, and deallocations.

Read how Object-Oriented Software Design in C++ explains big three →

100 C++ Mistakes and How to Avoid Them

The big 3 is the C++ special-member-function set consisting of a copy constructor, copy assignment operator, and destructor.

How it is used
Uses the big three to preserve correctness when classes manage dynamic or limited resources.
How deep it goes
Explains copying and destruction through shared-resource failure, deep copying, assignment, and move-enabled modernization.
Examples
Uses Page and TextSection listings to contrast shared pointers, uniqueness-preserving copies, and defaulted move operations.
What you can do after
Apply it by implementing deep-copy construction, copy assignment, and destruction, then modernize ownership with unique_ptr and move operations.

Read how 100 C++ Mistakes and How to Avoid Them explains big three →

Learn C++ by Example

The rule of three is a C++ resource-management guideline stating that a class defining a destructor, copy constructor, or copy assignment operator will generally need to define all three.

How it is used
Guides resource-owning class design and prompts checks of generated special member functions.
How deep it goes
Defines the guideline and links it to move operations, but stops short of implementing ownership or copy behavior.
Examples
Uses an abstract Blob type, static type-trait assertions, and vector push_back overloads to expose copying and moving behavior.
What you can do after
Evaluate whether a class supports destruction, copying, moving, and construction through C++ type traits.

Read how Learn C++ by Example explains big three →

Related concepts

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.