Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
# Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)
## 【One-Line Pitch】
The essential "second book" for any C++ developer, this classic distills 25 years of hard-won expertise into 55 concrete, actionable guidelines that bridge the gap between knowing C++ syntax and writing professional-grade, efficient, and maintainable code. If you've finished an introductory C++ course and want to think like an expert, this is your next read.
## 【Book Arc】
- **Opening (~0%–10%)**: The translator's preface and table of contents set the stage, framing the book as a "high-density accumulation of expert experience" — a collection of 55 independent "items" (条款) organized into 9 thematic chapters, from basic habits to advanced template metaprogramming.
- **Early (~10%–23%)**: Chapter 1 establishes foundational habits: viewing C++ as a federation of four sub-languages, preferring `const`, `enum`, and `inline` over `#define`, and the critical discipline of always initializing objects before use — including the member initialization list rule and the local-static-object pattern for cross-translation-unit initialization order.
- **Early (~23%–32%)**: Chapters 2–3 dive into the "big three" (construction, destruction, assignment) and resource management. Key insights include why virtual functions aren't virtual during base-class construction, the self-assignment/exception-safety connection in `operator=`, and the RAII principle with `shared_ptr` vs. `auto_ptr` trade-offs.
- **Middle (~32%–48%)**: Chapters 4–5 shift to design and declaration: making interfaces easy to use correctly and hard to misuse, avoiding object slicing via pass-by-reference, preferring non-member non-friend functions for encapsulation, and minimizing casts — with practical alternatives to `dynamic_cast`.
- **Late (~48%–100%)**: The remaining chapters cover advanced topics: templates and generic programming (including `typename`'s dual meaning, traits classes, and template metaprogramming), customizing `new`/`delete`, and final miscellany on compiler warnings, TR1, and Boost. The book closes with a new-vs-old edition item comparison table.
## 【Key Takeaways】
- **View C++ as a language federation** (Early): C++ is really four sub-languages — C, Object-Oriented C++, Template C++, and the STL — each with its own rules and idioms. Switching between them requires switching your mental model; this single insight explains many otherwise confusing behaviors.
- **Prefer the compiler over the preprocessor** (Early): Use `const`, `enum`, and `inline` instead of `#define` for constants and function-like macros. This gives you type safety, scoping, and debugger visibility — things the preprocessor can never provide.
- **Always initialize objects before use** (Early): C++ doesn't guarantee initialization for built-in types, and constructors must use member initialization lists (in declaration order) rather than assignment. For non-local static objects across translation units, replace them with local static objects to avoid initialization-order fiascoes.
- **Make copying functions complete and non-redundant** (Early): When writing copy constructors and copy assignment operators, copy *all* data members and *all* base-class components. Never have one copying function call the other — extract shared logic into a private `init` function instead.
- **Use RAII objects to manage resources** (Early): Acquire resources in constructors and release them in destructors. Prefer `tr1::shared_ptr` over `auto_ptr` because its copy behavior is intuitive; `auto_ptr`'s copy transfers ownership and nulls the source.
- **Design interfaces that are easy to use correctly and hard to misuse** (Middle): Consistency with built-in types, creating new types to constrain operations, and using `shared_ptr` with custom deleters (which can handle DLL issues and auto-unlock mutexes) all promote correct usage.
- **Prefer non-member non-friend functions for encapsulation** (Middle): Counter-intuitively, non-member functions increase encapsulation because fewer functions can access private data. This also improves packaging flexibility and reduces compilation dependencies.
- **Minimize casting — it breaks the type system** (Middle): C++ casts are more dangerous than in C/Java/C#. Prefer container-based designs with type-safe vectors over `dynamic_cast` chains; when you must cast, use the new-style casts and understand their costs.
## 【Reading Tips】
- **Skim the table of contents first** (~10%): The 55 items are independent, so treat this as a reference — read the chapters most relevant to your current work, not necessarily front-to-back.
- **Deep-read Chapters 1–3** (~10%–32%): These foundational items (initialization, copying, RAII) are the most universally applicable and will change how you write every class. Pay special attention to Item 4 (initialization) and Item 11 (self-assignment/exception safety).
- **Watch for the "Remember" boxes**: Each item ends with a bulleted summary — use these for quick review and as a checklist for code reviews.
- **Be patient with the template chapters** (~48%+): Items 42–48 on `typename`, traits, and template metaprogramming are the densest material. Skim them first, then return when you actually need these advanced techniques.
- **Pair with the companion volume**: The translator recommends *More Effective C++* as a follow-up — this third edition covers the modern language features, while the companion handles additional edge cases.
## 【Coverage Limits】
The excerpts cover the book's structure, foundational items (1–4, 5–6, 9–11, 13–15, 18, 20–24, 26–27), and the table of contents for later chapters, but do not include detailed content for items 28–52. Specific code examples for advanced topics (template metaprogramming, custom memory management) are not fully represented in this guide.
##
Page 12
有效率,又要有弹性,又要前瞻塑远,又要回溯相 容,又要治大国,又要烹小鲜,学习起来当然就不可能太简单。在庞大复杂的机制 下,万千使用者前仆后继的动力是:一旦学成,妙用无穷。 C++相关书籍车载斗覃,如天上繁星,如过江之渔卧广博如四库全书者有之(The C++ Programming Language、 C++ P...
Accustoming Yourself to C++ 不论你的编程背景是什么, C++ 都可能让你觉得有点儿熟悉。它是一个威力 强大的语言,带着众多特性,但是在你可以驾驭其威力并有效运用其特性之前,你 必须先习惯 C++的办事方式。本书谈的便是这个。总有某些东西比其他更基础些, 本章就是最基本的一些东西。 条款...
public File {...) ; class OutputFile: public File {...); class IOFile: public InputFile, public Ou七putFile 任何时候如果你有一个继承体系而其中某个base class 和某个 derived class 之间...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Effective C++ 改善程序与设计的55个具体做法(第3版) (Scott Meyers, 侯捷 译)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share to WeChat Moments
Effective C++ 改善程序与设计的55个具体做法(第3版) (Scott Meyers, 侯捷 译)(Z-Library)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Effective C++ 改善程序与设计的55个具体做法(第3版) (Scott Meyers, 侯捷 译)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment