Effective C++中文版[电子资源.图书]:改善程序设计与设计思维的50个有效做法
副标题:无
分类号:
ISBN:9787560925257
微信扫一扫,移动浏览光盘
简介
您手上这本书,是世界顶级C++大师Scott Meyers成名之作的第二版。其第一版诞生于1991年。在国际上,本书所引起的反响之大,波及整个计算机技术出版领域,余音至今未绝。几乎在所有C++书籍的推荐名单上,本书都会位于前三名。作者高超的技术把握力,独特的视角、诙谐轻松的写作风格、独具匠心的内容组织,都受到极大的推崇和仿效。甚至连本书简洁明快的命名风格,也有着一种特殊的号召力,我可以轻易列举出一大堆类似名字,比如Meyers本人的More Effective C++和Effective STL,Don Box的Effective COM,Stan Lippman主编的Efficient C++系列,Herb Sutter的Exceptional C++等等。要知道,这可不是出版社的有意安排,而且上面这些作者,同样是各自领域里的绝顶大师,决非人云亦云、欺世盗名之辈。这种奇特的现象,只能解释为人们对这本书衷心的赞美和推崇。
然而这样一本掷地有声的C++世界名著,不仅迟迟未能出版简体中文版,而且在国内其声誉似乎也并不显赫。可以说在一年之前,甚至很少有C++的学习者听说过这本书,这实在是一种遗憾。今天,在很多人的辛勤努力之下,这本书终于能够展现在我们的面前,对于真正的C++程序员来说,这确实是一件值得弹冠相庆的事。
我是一名普通的C++爱好者,因为机缘巧合,有幸参与了这本书的繁简转译工作,这使我能够比较早地看到本书的原版和繁体中文版。在这里我必须表达对本书中文译者、台湾著名技术作家侯捷先生的敬意和感谢,因为在我看来,这本书的中文版在质量上较其英文版兄长分毫不差,任何人都知道,达到这一点是多么的困难。侯先生以其深厚的技术功底、卓越的语言能力和严谨细致的治学态度,为我们跨越了语言隔阂所带来的理解障碍,完整而生动地将原书的内容与精神表达无遗,更令人钦佩的是,中文版的行文风格与原文也达到了高度的统一,可谓神形兼备,实在令人赞叹!因此我非常乐意向大家推荐这本书,相信它会在带给您带给你技术享受的同时,也带给您阅读的享受。
曾经在网络讨论组中间看到这样的说法,C++程序员可以分成两类,读过Effective C++的和没读过的。或许有点夸张了,但无论如何,当您拥有这本书之后,就获得了迅速提升自己C++功力的一个契机。这本书不是读完一遍就可以束之高阁的快餐读物,也不是能够立刻解决手边问题的参考手册,而是需要您去反复阅读体会,极力融入自己思想之中,融入自己每一次敲击键盘的动作之中。C++是真正程序员的语言,背后有着精深的思想与无以伦比的表达能力,这使得它具有类似宗教般的魅力。希望这本书能够帮助您跨越C++的重重险阻,领略高处才有的壮美,做一个成功而快乐的C++程序员。
目录
译序(侯捷) v
目录(contents) vii
前言(preface) xiii
致谢(acknowledgments. 中文版略) xvii
导读(introduction) 001
改变旧有的c习惯(shifting from c to c++) 013
条款1:尽量以 const 和 inline 取代 #define 013
prefer const and inline to #define.
条款2:尽量以 [iostream] 取代 [stdio.h] 017
prefer [iostream] to [stdio.h].
条款3:尽量以 new 和 delete 取代 malloc() 和 free() 019
prefer new and delete to malloc and free.
条款4:尽量使用 c++ 风格的注释形式 021
prefer c++-style comments.
内存管理(memory management) 022
条款5:使用相同形式的 new 和 delete 023
use the same form in corresponding uses of new and delete.
条款6:记得在 destructor 中以delete 对付 pointer members 024
use delete on pointer members in destructors.
.条款7:为内存不足的状况预做准备 025
be prepared for out-of-memory conditions.
条款8:撰写 operator new 和 operator delete 时应遵行公约 033
adhere to convention when writing operator new and operator delete.
条款9:避免遮掩了 new 的正规形式 037
avoid hiding the "normal" form of new.
条款10:如果你写了一个operator new,
请对应也写一个operator delete 039
write operator delete if you write operator new.
构造函数、析构函数和assignment 运算符 049
constructors, destructors, and assignment operators
条款11:如果classes内动态配置有内存,请为此 class 宣告
一个 copy constructor 和一个 assignment 运算符 049
declare a copy constructor and an assignment operator
for classes with dynamically allocated memory.
条款12:在 constructor 中尽量以 initialization 取代 assignment 052
prefer initialization to assignment in constructors.
条款13:initialization list 中的 members 初始化排列次序应该
和其在 class 内的声明次序相同 057
list members in an initialization list in the order
in which they are declared.
条款14:总是让 base class 拥有 virtual destructor 059
make sure base classes have virtual destructors.
条款15:令 operator= 传回"*this 的 reference" 064
have operator= return a reference to *this.
条款16:在 operator= 中为所有的 data members 赋予内容 068
assign to all data members in operator=.
条款17:在 operator= 中检查是否"自己赋值给自己" 071
check for assignment to self in operator=.
类与函数之设计和声明 077
classes and functions: design and declaration
条款18:努力让接口完满且最小化 079
strive for class interfaces that are complete and minimal.
条款19:区分member functions, non-member functions和
friend functions三者 084
differentiate among member functions, non-member functions,
and friend functions.
条款20:避免将 data members 放在公开接口中 089
avoid data members in the public interface.
条款21:尽可能使用 const 091
use const whenever possible.
条款22:尽量使用 pass-by-reference(传址),
少用 pass-by-value(传值) 098
prefer pass-by-reference to pass-by-value.
条款23:当你必须传回object 时,不要尝试传回 reference 101
don’t try to return a reference when you must return an object.
条款24:在函数重载(function overloading)和
参数缺省化(parameter defaulting)之间,谨慎抉择 106
choose carefully between function overloading
and parameter defaulting.
条款25:避免对指针型别和数值型别进行重载 109
avoid overloading on a pointer and a numerical type.
条款26:防卫潜伏的 ambiguity(模棱两可)状态 113
guard against potential ambiguity.
条款27:如果不想使用编译器暗自产生的 member functions,
就应该明白拒绝它 116
explicitly disallow use of implicitly generated member functions
you don’t want.
条款28:尝试切割 global namespace(全域命名空间) 117
partition the global namespace.
类与函数之实现 123
classes and functions: implementation
条款29:避免传回内部数据的 handles 123
avoid returning "handles" to internal data.
条款30:避免写出member function,传回一个 non-const pointer 或
reference 并以之指向较低存取层级的 members 129
avoid member functions that return non-const pointers or
references to members less accessible than themselves.
条款31:千万不要传回"函数内 local 对象的 reference",
或是"函数内以 new 获得的指针所指的对象" 131
never return a reference to a local object or to
a dereferenced pointer initialized by new within the function.
条款32:尽可能延缓变量定义式的出现 135
postpone variable definitions as long as possible.
条款33:明智地运用 inlining 137
use inlining judiciously.
条款34:将文件之间的编译依赖关系(compilation dependencies)
降至最低 143
minimize compilation dependencies between files.
继承机制与面向对象设计 153
inheritance and object-oriented design
条款35:确定你的 public inheritance 模塑出 "isa" 的关系 154
make sure public inheritance models "isa."
条款36:区分"接口继承(interface inheritance)"和
"实现继承(implementation inheritance)" 161
differentiate between inheritance of interface and
inheritance of implementation.
条款37:绝对不要重新定义一个继承而来的非虚拟函数 169
never redefine an inherited nonvirtual function.
条款38:绝对不要重新定义一个继承而来的缺省参数值 171
never redefine an inherited default parameter value.
条款39:避免在继承体系中做 cast down(向下转型)的动作 173
avoid casts down the inheritance hierarchy.
条款40:通过 layering(分层技术)来模塑 has-a 或
is-implemented-in-terms-of 的关系 182
model "has-a" or "is-implemented-in-terms-of" through layering.
条款41:区分 inheritance 和 templates 185
differentiate between inheritance and templates.
条款42:明智地运用 private inheritance(私有继承) 189
use private inheritance judiciously.
条款43:明智地运用多继承(multiple inheritance,mi) 194
use multiple inheritance judiciously.
条款44:说出你的意思并了解你所说的每一句话 210
say what you mean; understand what you’re saying.杂项讨论(miscellany) 212
条款45:知道 c++(编译器)默默为我们完成和调用哪些函数 212
know what functions c++ silently writes and calls.
条款46:宁愿编译和连接时出错,也不要执行时才错 216
prefer compile-time and link-time errors to runtime errors. 219
ensure that non-local static objects are initialized
before they’re used.
条款48:不要对编译器的警告讯息视而不见 223
pay attention to compiler warnings.
条款49:尽量让自己熟悉 c++ 标准程序库 224
familiarize yourself with the standard library.
条款50:加强自己对 c++ 的了解 232
improve your understanding of c++.
目录(contents) vii
前言(preface) xiii
致谢(acknowledgments. 中文版略) xvii
导读(introduction) 001
改变旧有的c习惯(shifting from c to c++) 013
条款1:尽量以 const 和 inline 取代 #define 013
prefer const and inline to #define.
条款2:尽量以 [iostream] 取代 [stdio.h] 017
prefer [iostream] to [stdio.h].
条款3:尽量以 new 和 delete 取代 malloc() 和 free() 019
prefer new and delete to malloc and free.
条款4:尽量使用 c++ 风格的注释形式 021
prefer c++-style comments.
内存管理(memory management) 022
条款5:使用相同形式的 new 和 delete 023
use the same form in corresponding uses of new and delete.
条款6:记得在 destructor 中以delete 对付 pointer members 024
use delete on pointer members in destructors.
.条款7:为内存不足的状况预做准备 025
be prepared for out-of-memory conditions.
条款8:撰写 operator new 和 operator delete 时应遵行公约 033
adhere to convention when writing operator new and operator delete.
条款9:避免遮掩了 new 的正规形式 037
avoid hiding the "normal" form of new.
条款10:如果你写了一个operator new,
请对应也写一个operator delete 039
write operator delete if you write operator new.
构造函数、析构函数和assignment 运算符 049
constructors, destructors, and assignment operators
条款11:如果classes内动态配置有内存,请为此 class 宣告
一个 copy constructor 和一个 assignment 运算符 049
declare a copy constructor and an assignment operator
for classes with dynamically allocated memory.
条款12:在 constructor 中尽量以 initialization 取代 assignment 052
prefer initialization to assignment in constructors.
条款13:initialization list 中的 members 初始化排列次序应该
和其在 class 内的声明次序相同 057
list members in an initialization list in the order
in which they are declared.
条款14:总是让 base class 拥有 virtual destructor 059
make sure base classes have virtual destructors.
条款15:令 operator= 传回"*this 的 reference" 064
have operator= return a reference to *this.
条款16:在 operator= 中为所有的 data members 赋予内容 068
assign to all data members in operator=.
条款17:在 operator= 中检查是否"自己赋值给自己" 071
check for assignment to self in operator=.
类与函数之设计和声明 077
classes and functions: design and declaration
条款18:努力让接口完满且最小化 079
strive for class interfaces that are complete and minimal.
条款19:区分member functions, non-member functions和
friend functions三者 084
differentiate among member functions, non-member functions,
and friend functions.
条款20:避免将 data members 放在公开接口中 089
avoid data members in the public interface.
条款21:尽可能使用 const 091
use const whenever possible.
条款22:尽量使用 pass-by-reference(传址),
少用 pass-by-value(传值) 098
prefer pass-by-reference to pass-by-value.
条款23:当你必须传回object 时,不要尝试传回 reference 101
don’t try to return a reference when you must return an object.
条款24:在函数重载(function overloading)和
参数缺省化(parameter defaulting)之间,谨慎抉择 106
choose carefully between function overloading
and parameter defaulting.
条款25:避免对指针型别和数值型别进行重载 109
avoid overloading on a pointer and a numerical type.
条款26:防卫潜伏的 ambiguity(模棱两可)状态 113
guard against potential ambiguity.
条款27:如果不想使用编译器暗自产生的 member functions,
就应该明白拒绝它 116
explicitly disallow use of implicitly generated member functions
you don’t want.
条款28:尝试切割 global namespace(全域命名空间) 117
partition the global namespace.
类与函数之实现 123
classes and functions: implementation
条款29:避免传回内部数据的 handles 123
avoid returning "handles" to internal data.
条款30:避免写出member function,传回一个 non-const pointer 或
reference 并以之指向较低存取层级的 members 129
avoid member functions that return non-const pointers or
references to members less accessible than themselves.
条款31:千万不要传回"函数内 local 对象的 reference",
或是"函数内以 new 获得的指针所指的对象" 131
never return a reference to a local object or to
a dereferenced pointer initialized by new within the function.
条款32:尽可能延缓变量定义式的出现 135
postpone variable definitions as long as possible.
条款33:明智地运用 inlining 137
use inlining judiciously.
条款34:将文件之间的编译依赖关系(compilation dependencies)
降至最低 143
minimize compilation dependencies between files.
继承机制与面向对象设计 153
inheritance and object-oriented design
条款35:确定你的 public inheritance 模塑出 "isa" 的关系 154
make sure public inheritance models "isa."
条款36:区分"接口继承(interface inheritance)"和
"实现继承(implementation inheritance)" 161
differentiate between inheritance of interface and
inheritance of implementation.
条款37:绝对不要重新定义一个继承而来的非虚拟函数 169
never redefine an inherited nonvirtual function.
条款38:绝对不要重新定义一个继承而来的缺省参数值 171
never redefine an inherited default parameter value.
条款39:避免在继承体系中做 cast down(向下转型)的动作 173
avoid casts down the inheritance hierarchy.
条款40:通过 layering(分层技术)来模塑 has-a 或
is-implemented-in-terms-of 的关系 182
model "has-a" or "is-implemented-in-terms-of" through layering.
条款41:区分 inheritance 和 templates 185
differentiate between inheritance and templates.
条款42:明智地运用 private inheritance(私有继承) 189
use private inheritance judiciously.
条款43:明智地运用多继承(multiple inheritance,mi) 194
use multiple inheritance judiciously.
条款44:说出你的意思并了解你所说的每一句话 210
say what you mean; understand what you’re saying.杂项讨论(miscellany) 212
条款45:知道 c++(编译器)默默为我们完成和调用哪些函数 212
know what functions c++ silently writes and calls.
条款46:宁愿编译和连接时出错,也不要执行时才错 216
prefer compile-time and link-time errors to runtime errors. 219
ensure that non-local static objects are initialized
before they’re used.
条款48:不要对编译器的警告讯息视而不见 223
pay attention to compiler warnings.
条款49:尽量让自己熟悉 c++ 标准程序库 224
familiarize yourself with the standard library.
条款50:加强自己对 c++ 的了解 232
improve your understanding of c++.
Effective C++中文版[电子资源.图书]:改善程序设计与设计思维的50个有效做法
- 名称
- 类型
- 大小
光盘服务联系方式: 020-38250260 客服QQ:4006604884
云图客服:
用户发送的提问,这种方式就需要有位在线客服来回答用户的问题,这种 就属于对话式的,问题是这种提问是否需要用户登录才能提问
Video Player
×
Audio Player
×
pdf Player
×