Skip to content

Latest commit

 

History

History
21 lines (21 loc) · 1.84 KB

README.md

File metadata and controls

21 lines (21 loc) · 1.84 KB

More Effective C++ 35个改善编程与设计的有效方法

  • 基础议题(Basics)
    • 条款1:仔细区别pointers和reference (Distinguish between pointers and reference.)
    • 条款2:最好使用C++转型操作符 (Prefer C++-style casets.)
    • 条款3:绝对不要以多态(polymorphically)方式处理数组 (Never treat arrays polmorphically.)
    • 条款4:非必要不提供default constructors. (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:了解各种不同意义的newdelete(Understand the different meanings of new and delete.)
  • 异常(Exceptions)
    • 条款9:利用destructors避免泄露资源(Use destrustors to prevent resource leaks.)
    • 条款10:在constructors内组织资源泄露(Prevent exceptions from leaving destructors.)
    • 条款11:禁止异常(exceptions)流出destructors之外
    • 条款12:了解“抛出一个exception”与“传递一个参数”或“调用一个虚函数”之间的差异(Unerstand 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.)