- 出版社: Addison-Wesley Professional; 3 (2005年5月22日)
- 丛书名: Addison-Wesley Professional Computing Series
- 平装: 320页
- 语种： 英语
- ISBN: 0321334876
- 条形码: 0785342334876, 9780321334879
- 商品尺寸: 18.8 x 2.3 x 23.1 cm
- 商品重量: 535 g
- ASIN: 0321334876
- 用户评分: 2 条商品评论
- 亚马逊热销商品排名: 图书商品里排第530,648名 (查看图书商品销售排行榜)
Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition) (英语) 平装 – 2005年5月22日
Scott Meyers is one of the world's foremost authorities on C++, providing training and consulting services to clients worldwide. He is the author of the best-selling Effective C++ series of books (Effective C++, More Effective C++, and Effective STL) and of the innovative Effective C++ CD. He is consulting editor for Addison Wesley's Effective Software Development Series and is a founding member of the Advisory Board for The C++ Source (http://www.artima.com/cppsource). He holds a Ph.D. in Computer Science from Brown University. His web site is http://www.aristeia.com.
Chapter 1: Accustoming Yourself to C++ 11
Item 1: View C++ as a federation of languages. 11
Item 2: Prefer consts, enums, and inlines to #defines. 13
Item 3: Use const whenever possible. 17
Item 4: Make sure that objects are initialized before they’re used. 26
Chapter 2: Constructors, Destructors, and Assignment Operators 34
Item 5: Know what functions C++ silently writes and calls. 34
Item 6: Explicitly disallow the use of compiler-generated functions you do not want. 37
Item 7: Declare destructors virtual in polymorphic base classes. 40
Item 8: Prevent exceptions from leaving destructors. 44
Item 9: Never call virtual functions during construction or destruction. 48
Item 10: Have assignment operators return a reference to *this. 52
Item 11: Handle assignment to self in operator=. 53
Item 12: Copy all parts of an object. 57
Chapter 3: Resource Management 61
Item 13: Use objects to manage resources. 61
Item 14: Think carefully about copying behavior in resource-managing classes. 66
Item 15: Provide access to raw resources in resource-managing classes. 69
Item 16: Use the same form in corresponding uses of new and delete. 73
Item 17: Store newed objects in smart pointers in standalone statements. 75
Chapter 4: Designs and Declarations 78
Item 18: Make interfaces easy to use correctly and hard to use incorrectly. 78
Item 19: Treat class design as type design. 84
Item 20: Prefer pass-by-reference-to-const to pass-by-value. 86
Item 21: Don’t try to return a reference when you must return an object. 90
Item 22: Declare data members private. 94
Item 23: Prefer non-member non-friend functions to member functions. 98
Item 24: Declare non-member functions when type conversions should apply to all parameters. 102
Item 25: Consider support for a non-throwing swap. 106
Chapter 5: Implementations 113
Item 26: Postpone variable definitions as long as possible. 113
Item 27: Minimize casting. 116
Item 28: Avoid returning “handles” to object internals. 123
Item 29: Strive for exception-safe code. 127
Item 30: Understand the ins and outs of inlining. 134
Item 31: Minimize compilation dependencies between files. 140
Chapter 6: Inheritance and Object-Oriented Design 149
Item 32: Make sure public inheritance models “is-a.” 150
Item 33: Avoid hiding inherited names. 156
Item 34: Differentiate between inheritance of interface and inheritance of implementation. 161
Item 35: Consider alternatives to virtual functions. 169
Item 36: Never redefine an inherited non-virtual function. 178
Item 37: Never redefine a function’s inherited default parameter value. 180
Item 38: Model “has-a” or “is-implemented-in-terms-of” through composition. 184
Item 39: Use private inheritance judiciously. 187
Item 40: Use multiple inheritance judiciously. 192
Chapter 7: Templates and Generic Programming 199
Item 41: Understand implicit interfaces and compile-time polymorphism. 199
Item 42: Understand the two meanings of typename. 203
Item 43: Know how to access names in templatized base classes. 207
Item 44: Factor parameter-independent code out of templates. 212
Item 45: Use member function templates to accept “all compatible types.” 218
Item 46: Define non-member functions inside templates when type conversions are desired. 222
Item 47: Use traits classes for information about types. 226
Item 48: Be aware of template metaprogramming. 233
Chapter 8: Customizing new and delete 239
Item 49: Understand the behavior of the new-handler. 240
Item 50: Understand when it makes sense to replace new and delete. 247
Item 51: Adhere to convention when writing new and delete. 252
Item 52: Write placement delete if you write placement new. 256
Chapter 9: Miscellany 262
Item 53: Pay attention to compiler warnings. 262
Item 54: Familiarize yourself with the standard library, including TR1. 263
Item 55: Familiarize yourself with Boost. 269
Appendix A: Beyond Effective C++ 273
Appendix B: Item Mappings Between Second and Third Editions 277
C/C++ to me is about your progression in learning the language. Most people start out small begin learning and slow progress to much larger programs. As you make your way to these larger programs you run into some fundamental logic flaws (or design flaws). This book helps shed some very useful and en lighting information on these flaws. Be it you think it's a language flaw or design flaw in your programming. This book will give you some very useful tools to be used medium to large scale c++ programs. It is a most definitely on my recommendation of books to read for a C++ programmer.
First, I recommend starting with some FREE books you can find on the Internet - called "Thinking in C++" by Bruce Eckel. There are 2 volumes and I recommend both. You can buy the print versions but I used the electronic versions.
I then read this book - Effective C++. Of course there is some repetition, but I like it as it helps 'drive stuff into my head'.
The next book I'll read is Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library.
I bought Effective C++ Third Edition in May 2013 from Amazon as the seller, and received the thirteenth printing (March 2013)
While some of this stuff seems dated in 2013, I think 98% of it is still quite relevant, though I do wish they would keep the books a bit more updated (no more than 4 or 5 years old).
I do plan on looking into a book on C++11 in the near future.
Bottom line for this book is that I found it well worth the price. It's much easier and cheaper to learn the stuff in this book by reading it instead of having to 'learn it the hard way'.
Let's divide up the task of becoming a C++ software engineer specialising in programming challenging systems ...
(1) learning the essentials of programming;
(2) learning the essentials of low level programming with its bit fiddling logical operators and implementation issues;
(3) learning C++ syntax;
(4) learning C++ development tools;
(5) picking up knowledge of the situational logic of software engineering;
(6) picking up knowledge of object oriented and procedural and other approaches to programming solutions to given problems and picking up the common sense to know the best approach to a given problem;
(7) learning C++ libraries;
(8) learning STL the standard template library;
(9) picking up knowledge so that one can develop an appropriate C++ style to the task at hand, whatever the task at hand may be ... knowing that educational miniprojects and real medium sized to large systems have different needs in this respect.
In this matter I am trying to distinguish knowledge and skills. I maintain that this book essentially deals with topics (2) (5) (6) (7) and (9) as outlined above, with application to the perculiarities of C++. In other words, this is an advanced work and should not be the first C++ book a first year university student should buy! First things first you need to buy a language primer ...
Nevertheless once one has mastered the basics of C++ this is an excellent work to start picking up rules of C++ style. Helpfully the author includes a number of items which describe typical C++ blunders that result from inadequate mastery of the basics of C++. Therefore after learning the basics of C++ most students would benefit by reading this book cover to cover! The explanations are clear and terse and if contemplated will enable many a conceptual misunderstanding of typical C++ semantics in C++ typical implementations to be clarified.
From earlier editions some of the advice has changed. There is a helpful table pp277-9 that describes a mapping of relevant items between the 2nd and 3rd editions! That the author has consolidated and clarified his advice on good C++ style is a good thing given how often he is cited in both industry and academia. Some advice has been updated to deal with the C++ 11 standard adopted two years ago; some has been updated to deal with the latest in C++ development technologies and libraries ...
Well worth reading even for the experienced programmer. Well worth buying even if you have an earlier edition. I really must find time now to read this properly cover to cover ... as I've read two of his earlier works!