高质量C C 编程指南_林锐.pdf
目 录前 言 .......................................................................................................................................6第 1 章 文件结构....................................................................................................................81.1 版权和版本的声明........................................................................................................81.2 头文件的结构 ...............................................................................................................81.3 定义文件的结构 ...........................................................................................................81.4 头文件的作用 ...............................................................................................................81.5 目录结构 .......................................................................................................................8第 2 章 程序的版式................................................................................................................82.1 空行 ...............................................................................................................................82.2 代码行 ...........................................................................................................................82.3 代码行内的空格 ...........................................................................................................82.4 对齐 ...............................................................................................................................82.5 长行拆分 .......................................................................................................................82.6 修饰符的位置 ...............................................................................................................82.7 注释 ...............................................................................................................................82.8 类的版式 .......................................................................................................................8第 3 章 命名规则....................................................................................................................83.1 共性规则 .......................................................................................................................83.2 简单的 WINDOWS 应用程序命名规则 .........................................................................83.3 简单的 UNIX 应用程序命名规则..................................................................................8第 4 章 表达式和基本语句 ....................................................................................................84.1 运算符的优先级 ...........................................................................................................84.2 复合表达式 ...................................................................................................................84.3 IF 语句 ...........................................................................................................................84.4 循环语句的效率 ...........................................................................................................84.5 FOR 语句的循环控制变量 ............................................................................................84.6 SWITCH 语句 ..................................................................................................................84.7 GOTO 语句......................................................................................................................8第 5 章 常量............................................................................................................................85.1 为什么需要常量 ...........................................................................................................85.2 CONST 与 #DEFINE 的比较 ...........................................................................................85.3 常量定义规则 ...............................................................................................................85.4 类中的常量 ...................................................................................................................8第 6 章 函数设计....................................................................................................................8 高质量 C /C 编程指南,v 1.02001 Page 4 of 1016.1 参数的规则 ...................................................................................................................86.2 返回值的规则 ...............................................................................................................86.3 函数内部实现的规则....................................................................................................86.4 其它建议 .......................................................................................................................86.5 使用断言 .......................................................................................................................86.6 引用与指针的比较........................................................................................................8第 7 章 内存管理....................................................................................................................87.1 内存分配方式 ................................................................................................................87.2 常见的内存错误及其对策.............................................................................................87.3 指针与数组的对比 ........................................................................................................87.4 指针参数是如何传递内存的?.....................................................................................87.5 FREE 和 DELETE 把指针怎么啦?.................................................................................87.6 动态内存会被自动释放吗? ........................................................................................87.7 杜绝“野指针” ...........................................................................................................87.8 有了 MALLOC/FREE 为什么还要 NEW/DELETE ?.......................................................87.9 内存耗尽怎么办?........................................................................................................87.10 MALLOC/FREE 的使用要点 .........................................................................................87.11 NEW/DELETE 的使用要点 ...........................................................................................87.12 一些心得体会 .............................................................................................................8第 8 章 C 函数的高级特性 .................................................................................................88.1 函数重载的概念 ...........................................................................................................88.2 成员函数的重载、覆盖与隐藏 ....................................................................................88.3 参数的缺省值 ...............................................................................................................88.4 运算符重载 ...................................................................................................................88.5 函数内联 .......................................................................................................................88.6 一些心得体会 ...............................................................................................................8第 9 章 类的构造函数、析构函数与赋值函数 .....................................................................89.1 构造函数与析构函数的起源 ........................................................................................89.2 构造函数的初始化表....................................................................................................89.3 构造和析构的次序........................................................................................................89.4 示例:类 STRING 的构造函数与析构函数 ..................................................................89.5 不要轻视拷贝构造函数与赋值函数 ............................................................................89.6 示例:类 STRING 的拷贝构造函数与赋值函数 ..........................................................89.7 偷懒的办法处理拷贝构造函数与赋值函数.................................................................89.8 如何在派生类中实现类的基本函数 ............................................................................89.9 一些心得体会 ...............................................................................................................8第 10 章 类的继承与组合 ......................................................................................................8 高质量 C /C 编程指南,v 1.02001 Page 5 of 10110.1 继承 .............................................................................................................................810.2 组合 .............................................................................................................................8第 11 章 其它编程经验 ..........................................................................................................811.1 使用 CONST 提高函数的健壮性..................................................................................811.2 提高程序的效率..........................................................................................................811.3 一些有益的建议..........................................................................................................8参考文献 .................................................................................................................................8附录 A :C /C 代码审查表 ................................................................................................8附录 B :C /C 试题 ............................................................................................................8附录 C :C /C 试题的答案与评分标准.............................................................................8
评论