C++ / a working model

BOOK / SOURCE & READING RECORD

Effective C++: 55 Specific Ways to Improve Your Programs and Designs

Scott Meyers

3rd edition, 2005; accessed English ebook identifies second release April 2011, essentially 11th paper printing

READING EVIDENCE / Full text read

Effective C++: 55 Specific Ways to Improve Your Programs and Designs

Have read paragraph by paragraph the entire technical body of the third English edition, Items 1–55 (print pages 1–272) and Appendices A/B (273–279), plus reread paragraphs missed in conversion such as the end of Item 26; also checked figure by figure the scope, strategy, and inheritance diagrams on PDF pages 177–180, 197, 202, 214–215, and 219. full means all technical items and appendices; marketing pages and the index were not item-by-item verified as part of the technical read-through. This is not merely downloading, looking at the table of contents, or reading sample chapters.

Edition, actual reading range, and original sources →

Sources

Write construction dependencies into parameters rather than expecting downward dispatch

Item 9, pp.48–52; Item 27, pp.119–120

The most useful insight from Item 9 is not mechanically forbidding a keyword, but treating how ready the object is as an interface premise. During base-class construction the derived state that has not yet been constructed is unknown; when a derived strategy is needed, let the caller or a static helper compute the configuration first and then pass it by value to the base class. Item 27's analysis of temporary base-class copies also hints that what looks like a change of calling convention may already have swapped objects. When reviewing initialization code, track both the call target and which object the data belongs to. As of C++20 this object-lifetime boundary still exists; override can only check signatures and cannot make derived state ready early. The item title is a design recommendation and does not mean that every ordinary virtual call during construction is illegal.

Related fundamentals

Construction and destruction orderStatic and Dynamic Polymorphism, Slicing, and RTTIThe Four Casts: Conversion Intent and Safety PreconditionsType traits and if constexpr compile-time branching

Original practice →