C++ / a working model

BOOK / SOURCE & READING RECORD

Thinking in C++

Bruce Eckel(Volume1);Bruce Eckel and Chuck Allison(Volume2)

2nd edition:Volume1 2000,HTML更新2001-09-27;Volume2 2004

READING EVIDENCE / Full text read

Thinking in C++

The two volumes are recorded as the same work: consecutive reading of Volume 1 chapters 1–16, appendices A–C, preface, and all end-of-chapter exercises/footnotes; Volume 2 chapters 1–11, appendices A/B, introduction, index, and footnotes 1–162. In addition, the images attached to the HTML of both volumes were read directly, one by one, to complete the class diagrams, layout diagrams, and recurrence formulas missing from the plain text. Exercises were not executed; separately sold solutions, CD recordings, and external linked materials are not included in the read scope. Complete reading does not mean that historical examples comply with C++20.

Edition, actual reading range, and original sources →

Sources

From cleanup actions toward responsibility boundaries

Vol1 Chapter6 Initialization & Cleanup、Chapter13 Dynamic Object Creation;Vol2 Chapter1 Resource management / Exception safety、Chapter11 Concurrency

Volume 1 connects initialization and cleanup to the object lifetime, and Volume 2 then uses exceptions to examine whether this design really holds. Together they point out: when a function discovers failure, it does not need to know at the same time how the upper layer should recover; local objects can be responsible for cleanup, while the upper layer retains business decisions. But resource cleanup and state rollback are different; a container not leaking does not mean a modification has the strong guarantee. This site's examples use a local candidate configuration and a single commit to demonstrate this difference, rather than copying auto_ptr or handwritten byte containers. The original book's ZThread, dynamic exception specifications, and old function adapters belong to the historical background; volatile has never provided modern thread synchronization. The ideas of ownership, contracts, and separating changes should be retained, while correcting boundary errors in the examples that can be statically identified.

Related fundamentals

RAII: Give Cleanup Responsibility to ObjectsException Safety: Guarantees, noexcept, and Commit PointsDestructors, exceptions, and noexcept

Original practice →