《More Effective C++:35個改善編程與設計的有效方法》(中文版)china-pub電腦新書推薦
基本資料
原書名: More Effective C++: 35 New Ways to Improve Your Programs and Designs
原出版社: Addison-Wesley Professional
作者: (美)Scott Meyers
譯者: 侯捷
叢書名: 傳世經典書叢
出版社:電子工業出版社
ISBN:9787121125706
內容簡介
繼effective c++之後,scott meyers 於1996 推出這本“續集”。條款變得比較少,頁數倒是多了一些,原因是這次選材比“第一集”更高階,尤其是第5 章。meyers 將此章命名為技術(techniques),並明白告訴你,其中都是一些patterns,例如virtual constructors,smart pointers,reference counting,proxy classes,double dispatching……這一章的每個條款篇幅都達15~30 頁之多,實在讓人有“山重水複疑無路,柳暗花明又一村”之歎。
雖然出版年代稍嫌久遠,但本書並沒有第2 版,原因是當其出版之時(1996),c++ standard已經幾乎定案,本書即依當時的標準草案而寫,其與現今的c++標準規範幾乎相同。而且可能變化的幾個彈性之處,meyers也都有所說明與提示。讀者可以登入作者提供的網址,看看上下兩集的勘誤與討論(數量之多,令人驚恐。幸好多是技術討論或文字斟酌,並沒有什麼重大誤失)。
目錄
譯序(侯捷)
導讀(introduction)
基礎議題(basics)
條款1:仔細區別 pointers 和 references
distinguish between pointers and references.
條款2:最好使用 c++ 轉型操作符
prefer c++-style casts.
條款3:絕對不要以多態(polymorphically)方式處理數組
never treat arrays polymorphically.
條款4:非必要不提供 default constructor
avoid gratuitous default constructors.
操作符(operators)
條款5:對定製的“類型轉換函式”保持警覺
be wary of user-defined conversion functions.
條款6:區別 increment/decrement 操作符的
前置(prefix)和後置(postfix)形式
distinguish between prefix and postfix forms of increment
and decrement operators.
條款7:千萬不要重載&&,和, 操作符
never overload &&, , or ,.
.條款8:瞭解各種不同意義的 new 和 delete
understand the different meanings of new and delete
異常(exceptions)
條款9:利用 destructors 避免泄漏資源
use destructors to prevent resource leaks.
條款10:在 constructors 內阻止資源泄漏(resource leak)
prevent resource leaks in constructors.
條款11:禁止異常(exceptions)流出 destructors 之外
prevent exceptions from leaving destructors.
條款12:瞭解“拋出一個 exception”與“傳遞一個參數”
或“調用一個虛函數”之間的差異
understand how throwing an exception differs from
passing a parameter or calling a virtual function.
條款13:以 by reference 方式捕捉 exceptions
catch exceptions by reference.
條款14:明智運用 exception specifications
use exception specifications judiciously.
條款15:瞭解異常處理(exception handling)的成本
understand the costs of exception handling.
效率(efficiency)
條款16:謹記 80-20 法則
remember the 80-20 rule.
條款17:考慮使用 lazy evaluation(緩式評估)
consider using lazy evaluation.
條款18:分期攤還預期的計算成本
amortize the cost of expected computations.
條款19:瞭解臨時對象的來源
understand the origin of temporary objects.
條款20:協助完成“傳回值最佳化(rvo)”
facilitate the return value optimization.
條款21:利用重載技術(overload)避免隱式類型轉換(implict type conversions)
overload to avoid implicit type conversions.
條款22:考慮以操作符複合形式(op=)取代其獨身形式(op)
consider using op= instead of stand-alone op.
條款23:考慮使用其他程式庫
consider alternative libraries.
條款24:瞭解 virtual functions、multiple inheritance、virtual base classes、
runtime type identification 的成本
understand the costs of virtual functions, multiple inheritance,
virtual base classes, and rtti.
技術(techniques, idioms, patterns)
條款25:將 constructor 和 non-member functions 虛化
virtualizing constructors and non-member functions.
條款26:限制某個 class 所能產生的對象數量
limiting the number of objects of a class.
條款27:要求(或禁止)對象產生於 heap 之中
requiring or prohibiting heap-based objects.
條款28:smart pointers(智能指標)
條款29:reference counting(引用計數)
條款30:proxy classes(替身類、代理類)
條款31:讓函數根據一個以上的物件類型來決定如何虛化
making functions virtual with respect to more than one object.
雜項討論(miscellany)
條款32:在未來時態下發展程式
program in the future tense.
條款33:將非尾端類(non-leaf classes)設計為
抽象類別(abstract classes)
make non-leaf classes abstract.
條款34:如何在同一個程式中結合 c++ 和 c
understand how to combine c++ and c in the same program.
條款35:讓自己習慣於標準 c++ 語言
familiarize yourself with the language standard.
推薦讀物
auto_ptr 實現代碼
索引(一)(general index)
索引(二)(index of example classes,functions,and templtes)
圖書詳情及購買地址:http://www.china-pub.com/197665