C++高质量编程

 
Effective C++
Item 1:  Prefer const and inline to #define
Item 2:  Prefer <iostream> to <stdio.h>
Item 3:  Prefer new and delete to malloc and free
Item 4:  Prefer C++-style comments

Item 5:  Use the same form in corresponding uses of new and delete
Item 6:  Use delete on pointer members in destructors
Item 7:  Be prepared for out-of-memory conditions
Item 8:  Adhere to convention when writing operator new and operator delete
Item 9:  Avoid hiding the "normal" form of new
Item 10:  Write operator delete if you write operator new

Item 11:  Declare a copy constructor and an assignment operator for classes with dynamically allocated memory
Item 12:  Prefer initialization to assignment in constructors
Item 13:  List members in an initialization list in the order in which they are declared
Item 14:  Make sure base classes have virtual destructors
Item 15:  Have operator= return a reference to *this
Item 16:  Assign to all data members in operator=
Item 17:  Check for assignment to self in operator=

Item 18:  Strive for class interfaces that are complete and minimal
Item 19:  Differentiate among member functions, non-member functions, and friend functions
Item 20:  Avoid data members in the public interface
Item 21:  Use const whenever possible
Item 22:  Prefer pass-by-reference to pass-by-value
Item 23:  Don't try to return a reference when you must return an object Item 24:  Choose carefully between function overloading and parameter defaulting
Item 25:  Avoid overloading on a pointer and a numerical type
Item 26:  Guard against potential ambiguity
Item 27:  Explicitly disallow use of implicitly generated member functions you don't want
Item 28:  Partition the global namespace

Item 29:  Avoid returning "handles" to internal data
Item 30:  Avoid member functions that return non-const pointers or references to members less accessible than themselves
Item 31:  Never return a reference to a local object or to a dereferenced pointer initialized by new within the function
Item 32:  Postpone variable definitions as long as possible
Item 33:  Use inlining judiciously
Item 34:  Minimize compilation dependencies between files

Item 35:  Make sure public inheritance models "isa."
Item 36:  Differentiate between inheritance of interface and inheritance of implementation
Item 37:  Never redefine an inherited nonvirtual function
Item 38:  Never redefine an inherited default parameter value
Item 39:  Avoid casts down the inheritance hierarchy
Item 40:  Model "has-a" or "is-implemented-in-terms-of" through layering Item 41:  Differentiate between inheritance and templates
Item 42:  Use private inheritance judiciously
Item 43:  Use multiple inheritance judiciously
Item 44:  Say what you mean; understand what you're saying

Item 45:  Know what functions C++ silently writes and calls
Item 46:  Prefer compile-time and link-time errors to runtime errors
Item 47:  Ensure that non-local static objects are initialized before they're used
Item 48:  Pay attention to compiler warnings
Item 49:  Familiarize yourself with the standard library
Item 50:  Improve your understanding of C++
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
目 录 前 言6 第1 章 文件结构 1.1 版权和版本的声明. 1.2 头文件的结构. 1.3 定义文件的结构. 1.4 头文件的作用. 1.5 目录结构. 第2 章 程序的版式 2.1 空行. 2.2 代码行. 2.3 代码行内的空格. 2.4 对齐. 2.5 长行拆分. 2.6 修饰符的位置. 2.7 注释. 2.8 类的版式. 第3 章 命名规则 3.1 共性规则. 3.2 简单的WINDOWS 应用程序命名规则. 3.3 简单的UNIX 应用程序命名规则 第4 章 表达式和基本语句 4.1 运算符的优先级. 4.2 复合表达式. 4.3 IF 语句 4.4 循环语句的效率. 4.5 FOR 语句的循环控制变量. 4.6 SWITCH 语句. 4.7 GOTO 语句. 第5 章 常量 5.1 为什么需要常量. 5.2 CONST 与 #DEFINE 的比较. 5.3 常量定义规则. 5.4 类中的常量. 第6 章 函数设计 高质量C++/C 编程指南,v 1.0 2001 Page 4 of 101 6.1 参数的规则. 6.2 返回值的规则. 6.3 函数内部实现的规则. 6.4 其它建议. 6.5 使用断言. 6.6 引用与指针的比较. 第7 章 内存管理 7.1 内存分配方式 7.2 常见的内存错误及其对策 7.3 指针与数组的对比 7.4 指针参数是如何传递内存的? 7.5 FREE 和DELETE 把指针怎么啦? 7.6 动态内存会被自动释放吗?. 7.7 杜绝“野指针”. 7.8 有了MALLOC/FREE 为什么还要NEW/DELETE ?. 7.9 内存耗尽怎么办?. 7.10 MALLOC/FREE 的使用要点 7.11 NEW/DELETE 的使用要点. 7.12 一些心得体会 第8 章 C++函数的高级特性 8.1 函数重载的概念. 8.2 成员函数的重载、覆盖与隐藏. 8.3 参数的缺省值. 8.4 运算符重载. 8.5 函数内联. 8.6 一些心得体会. 第9 章 类的构造函数、析构函数与赋值函数 9.1 构造函数与析构函数的起源. 9.2 构造函数的初始化表. 9.3 构造和析构的次序. 9.4 示例:类STRING 的构造函数与析构函数 9.5 不要轻视拷贝构造函数与赋值函数. 9.6 示例:类STRING 的拷贝构造函数与赋值函数 9.7 偷懒的办法处理拷贝构造函数与赋值函数. 9.8 如何在派生类中实现类的基本函数. 9.9 一些心得体会. 第10 章 类的继承与组合. 高质量C++/C 编程指南,v 1.0 2001 Page 5 of 101 10.1 继承 10.2 组合 第11 章 其它编程经验. 11.1 使用CONST 提高函数的健壮性 11.2 提高程序的效率 11.3 一些有益的建议 参考文献 附录A :C++/C 代码审查表. 附录B :C++/C 试题. 附录C :C++/C 试题的答案与评分标准.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值