内容简介 · · · · · ·
继 Effective C++ 之後,Scott Meyers 於 1996 推出这本「续集」。条款变得比较少,页数倒是多了一些,原因是这次选材比「第一集」更高阶,尤其是第五章。Meyers 将此章命名为技术(Techniques),并明白告诉你,其中都是一些 patterns,例如 virtual ctors、smart pointers、reference counting、proxy classes,double dispatching┅等等。这一章的每个条款篇幅都在 15~30 页之谱,实在让人有「山穷水尽疑无路,柳暗花明又一村」之叹。虽然出版年代稍嫌久远,本书并没有第二版,原因是当其出版之时(1996),C++ Standard 已经几乎定案,本书即依当时的标准草案而写。其间与现今之 C++ 标准规格几乎相同。可能变化的几个弹性之处,Mey... (展开全部)
继 Effective C++ 之後,Scott Meyers 於 1996 推出这本「续集」。条款变得比较少,页数倒是多了一些,原因是这次选材比「第一集」更高阶,尤其是第五章。Meyers 将此章命名为技术(Techniques),并明白告诉你,其中都是一些 patterns,例如 virtual ctors、smart pointers、reference counting、proxy classes,double dispatching┅等等。这一章的每个条款篇幅都在 15~30 页之谱,实在让人有「山穷水尽疑无路,柳暗花明又一村」之叹。虽然出版年代稍嫌久远,本书并没有第二版,原因是当其出版之时(1996),C++ Standard 已经几乎定案,本书即依当时的标准草案而写。其间与现今之 C++ 标准规格几乎相同。可能变化的几个弹性之处,Meyers 也都有所说明与提示。读者可以连结作者提供的网址,看看上下两集的勘误与讨论(数量之多,令人惊恐。幸好多是技术讨论或文字斟酌,并没有什麽重大误失)。
目录 · · · · · ·
序导读1 基础议题2 操作符3 异常4 效率5 技术6 杂项讨论推荐读物索引
序导读1 基础议题2 操作符3 异常4 效率5 技术6 杂项讨论推荐读物索引
· · · · · · (收起)
· · · · · · (收起)
豆瓣成员常用的标签(共80个) · · · · · ·
喜欢读"More Effective C++中文版"的人也喜欢 · · · · · ·
按有用程度 按页码先后 最新笔记
-
第100页
Difference between pointer and reference: 1. reference cannot be null 2. reference must be initialized 3. reference always refers to the object with which it is initialized 4. operator [] return reference ================= Cast: static_cast is quite similar to the old c-style cast, the only difference is that static_cast cannot cast away constness; dynamic_cast is used to cast types in... (更多)Difference between pointer and reference:1. reference cannot be null2. reference must be initialized3. reference always refers to the object with which it is initialized4. operator [] return reference=================Cast:static_cast is quite similar to the old c-style cast, the only difference is that static_cast cannot cast away constness;dynamic_cast is used to cast types in a inheritance hierarchy: from base to derived class, etc. It will perform run-time check, if fails, return null;const_cast is used to cast away constness or volatilenessreinterpret_cast is a beast, don’t use it=================Never treat arrays polymorphically, this is because the compiler cannot figure out the meaning of (array+i). And the language specification says that the result of deleting an array of derived class objects through a base class pointer is undefined.=================The dilemma of “to-provide-a-default-constructor-or-not”: without default constructor, you may have problems in declaring array, using template, and virtual base class. However, with default constructor, you may have problem in dealing with invalid initialization value.void * rawMemory = operator new[] (10*sizeof(EquipmentPiece)); EquipmentPiece* bestPieces = static_cast<EquipmentPiece*>(rawMemory); for(int i=0; i<10; i++) new (bestPieces+i) EquipmentPiece( … );
=================Be careful about implicit type conversion: there are two possible ways for implicit type conversion (1) operator type () const; (2) single argument constructor or multiple argument constructor but with default values for all parameters but the first one.The solution to (1) is to have a explicit function call ( e.g. string.c_str() );The solution to (2) is to use proxy class=================prefix and postfix increment or decrement. ++i increment and fetch, i++ fetch and increment. the prefix is more efficient since there is no more temp variable need to be created and deleted. i++++ is wrong, but ++++i is OK. therefore when define prefix or postfix for user-defined type, follow that rule by:UPInt& operator++ () and const UPInt& operator++(int) by default the value of this parameter will be 0=================Never overload operators && || and , For && and ||, you basically violate the short-circuit rule and for , you cannot guarantee the “left and then right” sequence.=================void* operator new(size_t size) {}void operator delete(void* point) {}when calling new, it has two steps: (1) allocate memory by using operator new, (2) call the constructor to initialize the memory just allocated, when calling delete, two steps also (1) call the destructor (2) release the memory.placement new: new (buffer) Widget( size ); Placement new is to initialize a ready-there memory.If you are using placement new, you only need call destructor but not to release memory (because the memory is not allocated by you in the first place) (收起)2011-12-21 05:09:13 回应
-
第100页
Difference between pointer and reference: 1. reference cannot be null 2. reference must be initialized 3. reference always refers to the object with which it is initialized 4. operator [] return reference ================= Cast: static_cast is quite similar to the old c-style cast, the only difference is that static_cast cannot cast away constness; dynamic_cast is used to cast types in... (更多)Difference between pointer and reference:1. reference cannot be null2. reference must be initialized3. reference always refers to the object with which it is initialized4. operator [] return reference=================Cast:static_cast is quite similar to the old c-style cast, the only difference is that static_cast cannot cast away constness;dynamic_cast is used to cast types in a inheritance hierarchy: from base to derived class, etc. It will perform run-time check, if fails, return null;const_cast is used to cast away constness or volatilenessreinterpret_cast is a beast, don’t use it=================Never treat arrays polymorphically, this is because the compiler cannot figure out the meaning of (array+i). And the language specification says that the result of deleting an array of derived class objects through a base class pointer is undefined.=================The dilemma of “to-provide-a-default-constructor-or-not”: without default constructor, you may have problems in declaring array, using template, and virtual base class. However, with default constructor, you may have problem in dealing with invalid initialization value.void * rawMemory = operator new[] (10*sizeof(EquipmentPiece)); EquipmentPiece* bestPieces = static_cast<EquipmentPiece*>(rawMemory); for(int i=0; i<10; i++) new (bestPieces+i) EquipmentPiece( … );
=================Be careful about implicit type conversion: there are two possible ways for implicit type conversion (1) operator type () const; (2) single argument constructor or multiple argument constructor but with default values for all parameters but the first one.The solution to (1) is to have a explicit function call ( e.g. string.c_str() );The solution to (2) is to use proxy class=================prefix and postfix increment or decrement. ++i increment and fetch, i++ fetch and increment. the prefix is more efficient since there is no more temp variable need to be created and deleted. i++++ is wrong, but ++++i is OK. therefore when define prefix or postfix for user-defined type, follow that rule by:UPInt& operator++ () and const UPInt& operator++(int) by default the value of this parameter will be 0=================Never overload operators && || and , For && and ||, you basically violate the short-circuit rule and for , you cannot guarantee the “left and then right” sequence.=================void* operator new(size_t size) {}void operator delete(void* point) {}when calling new, it has two steps: (1) allocate memory by using operator new, (2) call the constructor to initialize the memory just allocated, when calling delete, two steps also (1) call the destructor (2) release the memory.placement new: new (buffer) Widget( size ); Placement new is to initialize a ready-there memory.If you are using placement new, you only need call destructor but not to release memory (because the memory is not allocated by you in the first place) (收起)2011-12-21 05:09:13 回应
-
第100页
Difference between pointer and reference: 1. reference cannot be null 2. reference must be initialized 3. reference always refers to the object with which it is initialized 4. operator [] return reference ================= Cast: static_cast is quite similar to the old c-style cast, the only difference is that static_cast cannot cast away constness; dynamic_cast is used to cast types in... (更多)Difference between pointer and reference:1. reference cannot be null2. reference must be initialized3. reference always refers to the object with which it is initialized4. operator [] return reference=================Cast:static_cast is quite similar to the old c-style cast, the only difference is that static_cast cannot cast away constness;dynamic_cast is used to cast types in a inheritance hierarchy: from base to derived class, etc. It will perform run-time check, if fails, return null;const_cast is used to cast away constness or volatilenessreinterpret_cast is a beast, don’t use it=================Never treat arrays polymorphically, this is because the compiler cannot figure out the meaning of (array+i). And the language specification says that the result of deleting an array of derived class objects through a base class pointer is undefined.=================The dilemma of “to-provide-a-default-constructor-or-not”: without default constructor, you may have problems in declaring array, using template, and virtual base class. However, with default constructor, you may have problem in dealing with invalid initialization value.void * rawMemory = operator new[] (10*sizeof(EquipmentPiece)); EquipmentPiece* bestPieces = static_cast<EquipmentPiece*>(rawMemory); for(int i=0; i<10; i++) new (bestPieces+i) EquipmentPiece( … );
=================Be careful about implicit type conversion: there are two possible ways for implicit type conversion (1) operator type () const; (2) single argument constructor or multiple argument constructor but with default values for all parameters but the first one.The solution to (1) is to have a explicit function call ( e.g. string.c_str() );The solution to (2) is to use proxy class=================prefix and postfix increment or decrement. ++i increment and fetch, i++ fetch and increment. the prefix is more efficient since there is no more temp variable need to be created and deleted. i++++ is wrong, but ++++i is OK. therefore when define prefix or postfix for user-defined type, follow that rule by:UPInt& operator++ () and const UPInt& operator++(int) by default the value of this parameter will be 0=================Never overload operators && || and , For && and ||, you basically violate the short-circuit rule and for , you cannot guarantee the “left and then right” sequence.=================void* operator new(size_t size) {}void operator delete(void* point) {}when calling new, it has two steps: (1) allocate memory by using operator new, (2) call the constructor to initialize the memory just allocated, when calling delete, two steps also (1) call the destructor (2) release the memory.placement new: new (buffer) Widget( size ); Placement new is to initialize a ready-there memory.If you are using placement new, you only need call destructor but not to release memory (because the memory is not allocated by you in the first place) (收起)2011-12-21 05:09:13 回应
书评 · · · · · · 我来评论这本书
热门评论 最新评论
熟悉的题目,熟悉的作者
-
- 小李飞刀(加入仪器党……) 意味着同样的质量和收获 行文一如既往的流畅幽默,虽然有少数单词不认得,读起来却没什么困难 除了exceptions里的几个item没看,其他基本都看完了 闲暇时翻翻感兴趣的item,用不着学院派式地从头到尾逐个遍历,挺好! next:《Inside the C++ Object Model》......2008-06-15 1/1有用来自 机械工业出版社2006版
More Effective C++中文版
-
- 涅瓦纳(一个沉默的观影者与读书人) 继 Effective C++ 之後,Scott Meyers 於 1996 推出这本「续集」。条款变得比较少,页数倒是多了一些,原因是这次选材比「第一集」更高阶,尤其是第五章。Meyers 将此章命名为技术(Techniques),并明白告诉你,其中都是一些 patterns,例如 virtual ctors、sma......2011-07-30
"More Effective C++中文版"的论坛 · · · · · ·
- Addison-Wesley Professional版 亚马逊 RMB 493.10
- 加入购书单 多本比价 批量购买 已在购书单
这本书的其他版本有售 · · · · · ·
这本书的其他版本 · · · · · · ( 全部5 )
- Addison-Wesley Professional版 1996-1-8 / 375人读过 / 有售
- 机械工业出版社版 2006-04-01 / 42人读过
- 机械工业版 2007-4 / 39人读过
- 碁峰版 2004 / 2人读过
以下豆列推荐 · · · · · · (全部)
- 程序员最应该读的图书(中译版) (hongqn)
- 『书』好好学习C++ (悟怡)
- C++四书五经 (笨笨)
- C++书单(转载) (海若)
- 学习C++语言 (五点半)
谁读这本书?
喜欢这本书的人常去的小组 · · · · · ·

- TAOCP (615)

- 学习发布会 (854)

- C++及编程 (5000)

- scheme (446)

- Python编程 (19022)

- 程序员(不看公告发豆油的... (4661)

- Vim (6205)

- Go Programming Language (257)
喜欢这本书的人关注的活动 · · · · · ·
订阅关于More Effective C++中文版的评论:
feed: rss 2.0











