📖 Book · cpp core · high
⚙️ The Rule of 0 / 3 / 5
The five special members, a from-scratch String that owns its buffer, and why the Rule of Zero wins.
The special member functions and the three rules that govern them: Rule of Three, Rule of Five (with a complete runnable String that owns a heap buffer — copy deep, move steal, destruct), the shallow-copy double-free the rules prevent, and the Rule of Zero that avoids writing any of them by owning no raw resources.
4 chapters▶ runnable code✦ in-depth animation
What this book covers
- 01Zero, three, five — what the rules say
- 02Rule of Five: a String that owns its buffer — run it
- 03Why the defaults bite: shallow copy → double free
- 04Rule of Zero: own nothing, write nothing — run it
Read it in full — runnable C++ + step-through animations
Every chapter of The Rule of 0 / 3 / 5 ships complete, editable code you compile and run in the browser, plus the same in-depth animations as the lessons.