Effective C++, Second Edition 190
Effective C++, Second Edition Contents
Dedication Preface Acknowledgments Introduction Shifting from C to C++ Item 1: Item 2: Item 3: Item 4: Prefer const and inline to #define. Prefer to . Prefer new and delete to malloc and free. Prefer C++-style comments.
Memory Management Item 5: Item 6: Item 7: Item 8: Item 9: Item 10: Use the same form incorresponding uses of new and delete. Use delete on pointer members in destructors. Be prepared for out-of-memory conditions. Adhere to convention when writing operator new and operator delete. Avoid hiding the "normal" form of new. Write operator delete if you write operator new.
Constructors, Destructors, and Assignment Operators Item 11: Item 12: Item 13: Item 14: Item 15: Declare a copy constructorand an assignment operator for classes with dynamically allocated memory. Prefer initialization to assignment in constructors. List members in an initialization list in the order in which they are declared. Make sure base classes have virtual destructors. Have operator= return a reference to *this.
file:///E|/Resources/C++/effective%20c++/Effective_C+++_CD/Effective_C+++_CD/EC/TOC.HTM (1 / 3)[2003-6-11 20:01:49]
Effective C++, 2E, 2E | Contents
Item 16: Item 17:
Assign to all data members in operator=. Check for assignment to self in operator=.
Classes and Functions: Design and Declaration Item 18: Item 19: Item 20: Item 21: Item 22: Item 23: Item 24: Item 25: Item 26: Item 27: Item 28: Strive for class interfaces that are complete and minimal. Differentiate among memberfunctions, non-member functions, and friend functions. Avoid data members in the public interface. Use const whenever possible. Prefer pass-by-reference to pass-by-value. Don't try to return a reference when you must return an object. Choose carefully between function overloading and parameter defaulting. Avoid overloading on a pointer and a numerical type. Guard against potential ambiguity.Explicitly disallow use of implicitly generated member functions you don't want. Partition the global namespace.
Classes and Functions: Implementation Item 29: Item 30: Item 31: Item 32: Item 33: Item 34: Avoid returning "handles" to internal data. Avoid member functions that return non-const pointers or references to members less accessible than themselves. Never return a reference to a local objector to a dereferenced pointer initialized by new within the function. Postpone variable definitions as long as possible. Use inlining judiciously. Minimize compilation dependencies between files.
Inheritance and Object-Oriented Design Item 35: Item 36: Make sure public inheritance models "isa." Differentiate between inheritance of interface and inheritance of implementation.file:///E|/Resources/C++/effective%20c++/Effective_C+++_CD/Effective_C+++_CD/EC/TOC.HTM (2 / 3) [2003-6-11 20:01:49]
Effective C++, 2E, 2E | Contents
Item 37: Item 38: Item 39: Item 40: Item 41: Item 42: Item 43: Item 44: Miscellany Item 45: Item 46: Item 47: Item 48: Item 49: Item 50: Afterword Index
Never redefine an inherited nonvirtual function. Never redefine an inherited default parameter value.Avoid casts down the inheritance hierarchy. Model "has-a" or "is-implemented-in-terms-of" through layering. Differentiate between inheritance and templates. Use private inheritance judiciously. Use multiple inheritance judiciously. Say what you mean; understand what you're saying.
Know what functions C++ silently writes and calls. Prefer compile-time and link-time errors to runtime errors. Ensurethat non-local static objects are initialized before they're used. Pay attention to compiler warnings. Familiarize yourself with the standard library. Improve your understanding of C++.
file:///E|/Resources/C++/effective%20c++/Effective_C+++_CD/Effective_C+++_CD/EC/TOC.HTM (3 / 3) [2003-6-11 20:01:49]
Effective C++, 2E
Dedication
For Nancy, without whom nothing would be much worth...
Regístrate para leer el documento completo.