Back to Basics: Designing Classes (part 2 of 2)
summary
Shows concrete rules and gotchas: use value initialization with {} or in-class initializers instead of empty default constructors; prefer member-initializer lists and delegating constructors; declare single-argument constructors explicit to avoid implicit conversions. Demonstrates surprising sizes: bool+float+bool is 12 bytes not 6, switching to double makes it 24, but reorder members to reduce padding (largest-first) drops it to 16. Const data members/delete assignment, overload const/non-const begin/end, and prefer iterator typedefs to encapsulate return types.
AI-written summary · about
chapters (31)
- 0:00Introduction
- 1:37Value initialization
- 6:12Default constructor
- 9:08Core guidelines
- 11:53Delegate constructors
- 13:12Inclass initializers
- 20:38Single argument constructors
- 21:53Order of data members
- 23:42Alignment
- 25:19Padding
- 26:28Double first
- 31:11Align data members
- 32:00Bit fields
- 34:49Const functions
- 36:44Types of const
- 40:41Return immutable
- 41:40Const correctness
- 43:13Unique pointer
- 44:39Cont
- 45:39Encapsulation
- 48:10Data
- 48:45encapsulate decisions
- 49:22const data members
- 49:34reference data members
- 49:55const and reference
- 51:18pointer and reference
- 51:44reference wrap
- 52:48one thing left
- 53:03bonus
- 57:52summary
- 58:41move
related talks
01h 02mBack to Basics: Initialization in C++
01h 00mBack to the basics: Namespaces 101
01h 02m“Modern C++ Design (part 1 of 2)”
01h 00mBack to Basics: (Range) Algorithms in C++
15mYou Might Not Need Classes
57mDesign Patterns - The Most Common Misconceptions (2 of N)
01h 03mBreaking Dependencies: The SOLID Principles
46mWords of Wisdom
