More Effective C++

Book description

More than 150,000 copies in print! Praise for Scott Meyers’ first book, Effective C++:

“I heartily recommend Effective C++ to anyone who aspires to mastery of C++ at the intermediate level or above.”
– The C/C++ User’s Journal

From the author of the indispensable Effective C++, here are 35 new ways to improve your programs and designs. Drawing on years of experience, Meyers explains how to write software that is more effective: more efficient, more robust, more consistent, more portable, and more reusable. In short, how to write C++ software that’s just plain better.

More Effective C++ includes:

  • Proven methods for improving program efficiency, including incisive examinations of the time/space costs of C++ language features

  • Comprehensive descriptions of advanced techniques used by C++ experts, including placement new, virtual constructors, smart pointers, reference counting, proxy classes, and double-dispatching

  • Examples of the profound impact of exception handling on the structure and behavior of C++ classes and functions

  • Practical treatments of new language features, including bool, mutable, explicit, namespaces, member templates, the Standard Template Library, and more. If your compilers don’t yet support these features, Meyers shows you how to get the job done without them.

  • More Effective C++ is filled with pragmatic, down-to-earth advice you’ll use every day. Like Effective C++ before it, More Effective C++ is essential reading for anyone working with C++.

    Table of contents

    1. Copyright
      1. Dedication
    2. Praise for More Effective C++: 35 New Ways to Improve Your Programs and Designs
    3. Addison-Wesley Professional Computing Series
    4. Acknowledgments
      1. The Items
      2. The Book
      3. The People
    5. Introduction
      1. The C++ in More Effective C++
      2. Conventions and Terminology
      3. Reporting Bugs, Making Suggestions, Getting Book Updates
    6. Basics
      1. Item 1: Distinguish between pointers and references
      2. Item 2: Prefer C++-style casts
      3. Item 3: Never treat arrays polymorphically
      4. Item 4: Avoid gratuitous default constructors
    7. Operators
      1. Item 5: Be wary of user-defined conversion functions
      2. Item 6: Distinguish between prefix and postfix forms of increment and decrement operators
      3. Item 7: Never overload &&, ||, or ,
      4. Item 8: Understand the different meanings of new and delete
        1. Placement new
        2. Deletion and Memory Deallocation
        3. Arrays
    8. Exceptions
      1. Item 9: Use destructors to prevent resource leaks
      2. Item 10: Prevent resource leaks in constructors
      3. Item 11: Prevent exceptions from leaving destructors
      4. Item 12: Understand how throwing an exception differs from passing a parameter or calling a virtual function
      5. Item 13: Catch exceptions by reference
      6. Item 14: Use exception specifications judiciously
      7. Item 15: Understand the costs of exception handling
    9. Efficiency
      1. Item 16: Remember the 80-20 rule
      2. Item 17: Consider using lazy evaluation
        1. Reference Counting
        2. Distinguishing Reads from Writes
        3. Lazy Fetching
        4. Lazy Expression Evaluation
        5. Summary
      3. Item 18: Amortize the cost of expected computations
      4. Item 19: Understand the origin of temporary objects
      5. Item 20: Facilitate the return value optimization
      6. Item 21: Overload to avoid implicit type conversions
      7. Item 22: Consider using op= instead of stand-alone op
      8. Item 23: Consider alternative libraries
      9. Item 24: Understand the costs of virtual functions, multiple inheritance, virtual base classes, and RTTI
    10. Techniques
      1. Item 25: Virtualizing constructors and non-member functions
        1. Making Non-Member Functions Act Virtual
      2. Item 26: Limiting the number of objects of a class
        1. Allowing Zero or One Objects
        2. Contexts for Object Construction
        3. Allowing Objects to Come and Go
        4. An Object-Counting Base Class
      3. Item 27: Requiring or prohibiting heap-based objects
        1. Requiring Heap-Based Objects
        2. Determining Whether an Object is On The Heap
        3. Prohibiting Heap-Based Objects
      4. Item 28: Smart pointers
        1. Construction, Assignment, and Destruction of Smart Pointers
        2. Implementing the Dereferencing Operators
        3. Testing Smart Pointers for Nullness
        4. Converting Smart Pointers to Dumb Pointers
        5. Smart Pointers and Inheritance-Based Type Conversions
        6. Smart Pointers and const
        7. Evaluation
      5. Item 29: Reference counting
        1. Implementing Reference Counting
        2. Copy-on-Write
        3. Pointers, References, and Copy-on-Write
        4. A Reference-Counting Base Class
        5. Automating Reference Count Manipulations
        6. Putting it All Together
        7. Adding Reference Counting to Existing Classes
        8. Evaluation
      6. Item 30: Proxy classes
        1. Implementing Two-Dimensional Arrays
        2. Distinguishing Reads from Writes via operator[]
        3. Limitations
        4. Evaluation
      7. Item 31: Making functions virtual with respect to more than one object
        1. Using Virtual Functions and RTTI
        2. Using Virtual Functions Only
        3. Emulating Virtual Function Tables
        4. Initializing Emulated Virtual Function Tables
        5. Using Non-Member Collision-Processing Functions
        6. Inheritance and Emulated Virtual Function Tables
        7. Initializing Emulated Virtual Function Tables (Reprise)
    11. Miscellany
      1. Item 32: Program in the future tense
      2. Item 33: Make non-leaf classes abstract
      3. Item 34: Understand how to combine C++ and C in the same program
        1. Name Mangling
        2. Initialization of Statics
        3. Dynamic Memory Allocation
        4. Data Structure Compatibility
        5. Summary
      4. Item 35: Familiarize yourself with the language standard
        1. The Standard Template Library
    12. Recommended Reading
      1. Books
      2. Magazines
      3. Usenet Newsgroups
    13. An auto_ptr Implementation

    Product information

    • Title: More Effective C++
    • Author(s):
    • Release date: December 1995
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 9780321545190