Effective C++ 目录

目 录
1 让自己习惯C++(View Yourself to C++)    1
1.1 条款1:视C++为一个语言联邦(View C++ as a federation of language)    1
1.2 条款2:尽量使用consts,enums和inlines,少用#define (Prefer consts,enums and inlines to #define)    1
1.3 条款3:尽可能使用const(Use const whenever possible)    2
1.3.1 const与指针    2
1.3.2 const与迭代器    2
1.3.3 const与成员函数    3
1.4 条款4:关于“将对象初始化”这事,C++似乎反复无常(Make sure that object are initialized before they’re used)    3
2 构造、析构和赋值运算(Constructors,Destructors and Assignment Operators)    5
2.1 条款5:了解C++默认编写并调用哪些函数(Know what functions C++ silently writes and calls)    5
2.2 条款6:若不想使用编译器自动生成的函数,就该明确拒绝(Explicitly disallow the use of compiler-generated function you do not want)    5
2.3 条款7:为多态基类声明virtual析构函数(Declare destructors virtual in polymorphic base class)    6
2.4 条款8:别让异常逃离析构函数(Prevent exception from leaving destructors)    7
2.5 条款9:绝不在构造和析构函数过程中调用virtual函数(Never call virtual function during construction or destruction)    9
2.6 条款10:令operator=返回一个refernce to *this (Have assignment operators return a reference to *this)    9
2.7 条款11:在operator=中处理“自我赋值”(Handle assignment to self in operator=)    9
2.8 条款12:复制对象时无妄其每一个成分(Copy all parts of an object)    11
3 资源管理(Resource Management)    13
3.1 条款13:以对象管理资源(Use object to manage resource)    13
3.2 条款14:在资源管理类中小心copying行为(Think carefully about copying behavior in resource-managing classes)    14
3.3 条款15:在资源管理类中提供对原始资源的访问(Provide access to raw resource in resource-managing classes)    15
3.4 条款16:成对使用new和delete时要采用相同形式(Use the same form in corresponding uses of new and delete)    15
3.5 条款17:以独立语句将newed对象置于智能指针(Store newed objects in smart pointers in standalone statement)    16
4 设计与声明    16
4.1 条款18:让接口容易被正确使用,不易被误用(Make interfaces easy to use correctly and hard to use incorrectly)    16
4.2 条款19:设计class犹如设计type(Treat class design as type design)    17
4.3 条款20:宁以pass-by-reference-to-const 替换pass-by-value (Prefer pass-by-reference-to-const to pass-by-value)    17
4.4 条款21:必须返回对象时,别妄想返回其reference(Don 't try to return a reference when you must return an object)    18
4.5 条款22:将成员变量声明为private(Declare data members private)    20
4.6 条款23:宁以non-member、non-friend替换member函数 (Prefer non-member non-friend functions to member functions)    20
4.7 条款24:若所有参数皆需类型转换,请为此采用non-member 函数(Declare non-member functions when type conversions should apply to all parameters)    21
4.8 条款25:考虑写出一个不抛异常的swap函数 (Consider support for non-throwing swap)    23
5 实现(Implementation)    26
5.1 条款26:尽可能延后变量定义式的出现时间(Postpone variable definitions as long as possible)    26
5.2 条款27:尽量少做转型动作 (Minimize casting)    27
5.3 条款28:避免返回Handles指向对象内部成分 (Avoid returning “handles” to object internals)    30
5.4 条款29:为” 异常安全”而努力是值得的 (Strive for exception-safe code)    32
5.5 条款30:透切了解inlining的里里外外 (Understand the ins and outs of inlining)    34
5.6 条款31:将文件间的编译依存关系降至最低 (Minimize compilation dependencies between files)    35
6 继承与面向对象(Inheritance and Object-Oriented Design)    37
6.1 条款32:确定你的public继承塑模出is-a关系 (Make sure public inheritance models “is-a”)    37
6.2 条款33:避免遮掩继承而来的名称 (Avoid hiding inherited names)    38
6.3 条款34:区分借口继承和实现继承 (Differentiate between inheritance of interface and inheritance of implementation)    41
6.4 条款35:考虑virtual函数以外的其他选择 (consider alternatives to virtual functions)    42
6.5 条款36:绝不重新定义继承而来的non-virtual函数 (Never redefine a function 's inherited non-virtual function)    46
6.6 条款37:绝不重新定义继承而来的缺省参数值(Never redefine a function 's inherited default parameter value)    47
6.7 条款38:通过复合塑模出has-a或“根据某实物实现出” (Mode "has-a" or  " is-implementation-in-terms-of" through composition)    48
6.8 条款39:明智而审慎地使用private继承(Use private inheritance judiciously)    48
6.9 条款40:明智而审慎地使用多重继承 (Use multiple inheritance judiciously)    50
7 模板与泛型编程 (Templates and Generic Programming)    53
7.1 条款41:了解隐式接口和编译期多态 (Understand implicit interface and compile-time polymorphism)    53
7.2 条款42:了解typename的双重意义 (Understand the two meaning of typename)    54
7.3 条款43:学习处理模板化基类内的名称 (Know how to access names in templatized base class)    56
7.4 条款44:将与参数无关的代码抽离templates (Factor parameter-independent code out of templates)    59
7.5 条款45:运用成员函数模板介绍所有兼容类型 (Use member function templates to accept "all compatible types")    61
7.6 条款46:需要类型转换时请为目标定义非成员函数 (Define non-member functions inside templates when type conversions are desired) 62
7.7 条款47:请使用traits classes表现类型信息 (Use traits classes for information about types)    64
7.8 条款48:认识template元编程 (Be aware of template metaprogramming)    67
8 定制new和delete(Customizing new and delete)    68
8.1 条款49:了解new-handler行为 (Understand the behavior of the new-handler)    68
8.2 条款50:了解new和delete的合理替换时机 (Understand when it makes sense to replace new and delete)    72
8.3 条款51:编写new和delete时需要固守成规 (Be aware of template metaprogramming)    72
8.4 条款52:写了placement new也要写placement delete (Be aware of template metaprogramming)    74
9 其他(Others)    77
9.1 C++关键字explicit    77
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
有人说c++程序员可以分成两类,读过effective c++的和没读过的。世界顶级c++大师scott meyers成名之作的第三版的确当得起这样的评价。当您读过这本书之后,就获得了迅速提升自己c++功力的一个契机。.(2-1)   在国际上,本书所引起的反响,波及整个计算技术出版领域,余音至今未绝。几乎在所有c++书籍的推荐名单上,本书都会位于前三名。作者高超的技术把握力、独特的视角。诙谐轻松的写作风格、独具匠心的内容组织,都受到极大的推崇和仿效。这种奇特的现象,只能解释为人们对这本书衷心的赞美和推祟。《effective c++》前两个版本的确抓住了全世界无数程序员的目光。原因十分显明:scott meyers 极富实践意义的c++ 研讨方式,描述出专家用以产出干净、正确、高效代码的经验法则和行事法则——也就是他们几乎总是做或不做的某些事。   这本书不是读完一遍就可以束之高阁的快餐读物,也不是用以解决手边问题的参考手册,而是需要您去反复阅读体会的,c++是真正程序员的语言,背后有着精深的思想与无与伦比的表达能力,这使得它具有类似宗教般的魅力。希望这本书自瞄帮助您跨越c抖的重重险阻,领略高处才有的壮美风光,做—个成功而快乐的c++程序员。...      本书一共组织 55 个准则,每一条准则描述一个编写出更好的 c++ 的方式。每一个条款的背后都有具体范例支撑。第三版有一半以上的篇幅是崭新内容,包括讨论资源管理和模板(templates)运用的两个新章。为反映出现代设计考虑,对第二版论题做了广泛的修订,包括异常(exceptions)、设计模式(design patterns)和多线程(multithreading)。      《effective c++》的重要特征包括:    * 高效的 classes、functions、templatesinheritance hierarchies(继承体系)方面的专家级指导。    * 崭新的 "tr1" 标准程序库功能应用,以及与既有标准程序库组件的比较。    * 洞察 c++和其他语言(例如java、c#、c)之间的不同。此举有助于那些来自其他语言阵营的开发人员消化吸收 c++ 式的各种解法。(2-1)
"更有效的C"中文版目录可以按照以下方式进行组织: 一、 前言 1.1 缘起 1.2 目的 1.3 结构说明 二、C语言的基础知识回顾 2.1 C语言概述 2.2 C语言编译与执行过程 2.3 C语言的数据类型及其使用 2.4 C语言的基本语法 2.5 C语言的运算符及其使用 ... 三、提高C程序的性能 3.1 优化C程序的方法论 3.2 硬件与软件环境对性能的影响 3.3 性能评估与测试工具 3.4 代码优化技巧与规范 3.5 内存管理与优化 ... 四、高级C编程技巧 4.1 指针与内存操作 4.2 结构体与联合体 4.3 动态内存分配 4.4 函数指针与回调 4.5 模块化与模块间通信 ... 五、并发与多线程编程 5.1 并发编程的基本概念 5.2 同步与互斥机制 5.3 线程创建与管理 5.4 线程间通信与同步 5.5 并发编程中的常见问题与解决方案 ... 六、异常处理与错误调试 6.1 异常处理的基本原则 6.2 错误处理与异常机制 6.3 断言与日志 6.4 调试技巧与工具使用 ... 七、C语言的扩展与应用 7.1 C语言标准库的扩展 7.2 C语言在系统编程中的应用 7.3 C语言在嵌入式编程中的应用 7.4 C语言在网络编程中的应用 7.5 C语言在游戏开发中的应用 ... 八、总结与展望 8.1 本书内容回顾 8.2 未来C语言发展趋势 8.3 结语 通过以上目录的组织,读者可以系统地了解C语言的基础知识及高级编程技巧,提高C程序的性能和效率,并扩展C语言的应用范围。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值