If you find this page useful, please consider making a quick and secure donation (powered by PayPal) to keep it free!
 
 

Knowledge Base/CPP/More Effective CPP

 

From The Thalesians

Jump to: navigation, search

This is essentially the table of contents of Scott Meyers' book More Effective C++. The same table of contents is available on Amazon.com, but not on Amazon.co.uk (check out the "Look Inside" feature). In my view, every serious C++ programmer should read Scott's book. Of course, you need to read the entire book. The chapter titles will only make sense if you have read it. If you haven't read it and the titles still make sense, you are still missing a lot. I would read the book.

Contents

Basics

  1. Distinguish between pointers and references
  2. Prefer C++-style casts
  3. Never treat arrays polymorphically
  4. Avoid gratuitious default constructors

Operators

  1. Be wary of user-defined conversion functions
  2. Distinguish between prefix and postfix forms of increment and decrement operators
  3. Never overload &&, ||, or ,
  4. Understand the different meanings of new and delete

Resource management

  1. Use destructors to prevent resource leaks
  2. Prevent resource leaks in constructors
  3. Prevent exceptions from leaving destructors
  4. Understand how throwing an exception differs from passing a parameter or calling a virtual function
  5. Catch exceptions by reference
  6. Use exception specifications judiciously
  7. Understand the costs of exception handling

Efficiency

  1. Remember the 80-20 rule
  2. Consider using lazy evaluation
  3. Ammortise the cost of expected computations
  4. Understand the origin of temporary objects
  5. Facilitate the return value optimisation
  6. Overload to avoid implicit type conversions
  7. Consider using op= instead of stand-alone op
  8. Consider alternative libraries
  9. Understand the costs of virtual functions, multiple inheritance, virtual base classes, and RTTI

Techniques

  1. Virtualising constructors and non-member functions
  2. Limiting the number of objects of a class
  3. Requiring or prohibiting heap-based objects
  4. Smart pointers
  5. Reference counting
  6. Proxy classes
  7. Making functions virtual with respect to more than one object

Miscellany

  1. Program in the future tense
  2. Make non-leaf classes abstract
  3. Understand how to combine C++ and C in the same program
  4. Familiarise yourself with the language standard

 
 
Google
 
Personal tools