《Effective C++》读书笔记 (系列)

  1. 1. Part 4: Designs and Declarations
  2. 2. Part 8: Customizing new and delete

去年读完 《C++ Primer》 一书,本以为对 C++ 基础部分已经窥探得差不多, 哪知 2011 年 9 月 C++ 标准委员会已经发布了 C++0x ,这样推算起来,我还是晚了一步。犹记得在谭浩强的书上,经常能看到关于 C++98 的注脚,谓为标准,结果 C++ 早已经经历了

Year

C++ Standard

Informal name

1998

ISO/IEC 14882:1998[18]

C++98

2003

ISO/IEC 14882:2003[19]

C++03

2007

ISO/IEC TR 19768:2007[20]

C++TR1

2011

ISO/IEC 14882:2011[21]

C++11



几轮迭代更新(若想打开上面的链接,需先研究 goagent+Chrome/Firefox翻墙教程),如此看来,吾等算是远远落后于时代了。

唯有快马加鞭,奋起直追。

且慢!学习 C++Ox 新特性固然重要,但是读完 《C++ Primer》 是否真具备了登高望远的资格?根据这些日子所见所识来看,未必。

于是,当前第一要务应当是更深入的学习 C++,知己知彼,方能百战不殆。

这是前话。

假前购入相关书籍数本,算是正式开始踏上继《C++ Primer》这本挺厚的垫脚石之后再一次往上攀爬。

第一本启封的,就是眼下这本 Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)

Effective C++: 55 Specific Ways To Improve Your Programs And Designs

一狠心买了英文版,好在读起还算顺利,鉴于此书字字珠玑,句句金玉,江湖上评价极高,为了加深记忆和日后复习方便,遂开始在阅读每个条款后记录下要点,顺便练练英语了。

读书笔记整理如下:

Part 4: Designs and Declarations

Item 20: Prefer pass-by-reference-to-const to pass-by-value.
Item 21: Don’t try to return a reference when you must return an object.
Item 22: Declare data members private.
Item 23: Prefer non-member non-friend functions to member functions.
Item 24: Declare non-member function when type conversions should apply to all parameters.
Item 25: Consider support for a non-throwing swap.

Part 8: Customizing new and delete

Item 49: Understand the behavior of the new-handler.