导读(Introduction)
基础议题(Basics)
条款1:仔细区别pointers和references
Distinguishbetweenpointersandreferences.
条款2:最好使用C++转型操作符
PreferC++-stylecasts.
条款3:绝对不要以多态(polymorphically)方式处理数组
Nevertreatarrayspolymorphically.
条款4:非必要不提供defaultconstructor
Avoidgratuitousdefaultconstructors.
操作符(Operators)
条款5:对定制的"类型转换函数"保持警觉
Bewaryofuser-definedconversionfunctions.
条款6:区别increment/decrement操作符的前置(prefix)和后置(postfix)形式
Distinguishbetweenprefixandpostfixformsofincrementanddecrementoperators.
条款7:千万不要重载&&,||和,操作符
Neveroverload&&,||,or,.
条款8:了解各种不同意义的new和delete
Understandthedifferentmeaningsofnewanddelete
异常(Exceptions)
条款9:利用destructors避免泄漏资源
Usedestructorstopreventresourceleaks.
条款10:在constructors内阻止资源泄漏(resourceleak)
Preventresourceleaksinconstructors.
条款11:禁止异常(exceptions)流出destructors之外
Preventexceptionsfromleavingdestructors.
条款12:了解"抛出一个exception"与"传递一个参数"或"调用一个虚函数"之间的差异
Understandhowthrowinganexceptiondiffersfrompassingaparameterorcallingavirtualfunction.
条款13:以byreference方式捕捉exceptions
Catchexceptionsbyreference.
条款14:明智运用exceptionspecifications
Useexceptionspecificationsjudiciously.
条款15:了解异常处理(exceptionhandling)的成本
Understandthecostsofexceptionhandling.
效率(Efficiency)
条款16:谨记80-20法则
Rememberthe80-20rule.
条款17:考虑使用lazyevaluation(缓式评估)
Considerusinglazyevaluation.
条款18:分期摊还预期的计算成本
Amortizethecostofexpectedcomputations.
条款19:了解临时对象的来源
Understandtheoriginoftemporaryobjects.
条款20:协助完成"返回值优化(RVO)"
Facilitatethereturnvalueoptimization.
条款21:利用重载技术(overload)避免隐式类型转换(implicttypeconversions)
Overloadtoavoidimplicittypeconversions.
条款22:考虑以操作符复合形式(op=)取代其独身形式(op)
Considerusingop=insteadofstand-aloneop.
条款23:考虑使用其他程序库
Consider alternativelibraries.
条款24:了解virtualfunctions、multipleinheritance、virtualbaseclasses、runtimetypeidentification的成本
Understandthecostsofvirtualfunctions,multipleinheritance,virtualbaseclasses,andRTTI.
技术(Techniques,Idioms,Patterns)
条款25:将constructor和non-memberfunctions虚化
Virtualizingconstructorsandnon-memberfunctions.
条款26:限制某个class所能产生的对象数量
Limitingthenumberofobjectsofaclass.
条款27:要求(或禁止)对象产生于heap之中
Requiringorprohibitingheap-basedobjects.
条款28:SmartPointers(智能指针)
条款29:Referencecounting(引用计数)
条款30:Proxyclasses(替身类、代理类)
条款31:让函数根据一个以上的对象类型来决定如何虚化
Makingfunctionsvirtualwithrespecttomorethanoneobject.
杂项讨论(Miscellany)
条款32:在未来时态下发展程序
Programinthefuturetense.
条款33:将非尾端类(non-leafclasses)设计为抽象类(abstractclasses)
Makenon-leafclassesabstract.
条款34:如何在同一个程序中结合C++和C
UnderstandhowtocombineC++andCinthesameprogram.
条款35:让自己习惯于标准C++语言
Familiarizeyourselfwiththelanguagestandard.
推荐读物
auto_ptr实现代码
索引(一)(GeneralIndex)
索引(二)(IndexofExampleClasses,Functions,andTempltes)