Skip to content

Commit

Permalink
更新 Effective C++
Browse files Browse the repository at this point in the history
  • Loading branch information
huihut committed Oct 18, 2018
1 parent b32f518 commit 2d6f80e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ class doSomething(Flyable *obj) // 做些事情
26. 尽可能延后变量定义式的出现时间(可增加程序清晰度并改善程序效率)
27. 尽量少做转型动作(旧式:`(T)expression``T(expression)`;新式:`const_cast<T>(expression)``dynamic_cast<T>(expression)``reinterpret_cast<T>(expression)``static_cast<T>(expression)`、;尽量避免转型、注重效率避免 dynamic_casts、尽量设计成无需转型、可把转型封装成函数、宁可用新式转型)
28. 避免使用 handles(包括 引用、指针、迭代器)指向对象内部(以增加封装性、使 const 成员函数的行为更像 const、降低 “虚吊号码牌”(dangling handles,如悬空指针等)的可能性)
29.`异常安全` 而努力是值得的(异常安全函数(Exception-safe functions)即使发生异常也不会泄露资源或允许任何数据结构败坏,分为三种可能的保证:基本型、强列型、不抛异常型)
29.异常安全 而努力是值得的(异常安全函数(Exception-safe functions)即使发生异常也不会泄露资源或允许任何数据结构败坏,分为三种可能的保证:基本型、强列型、不抛异常型)
30. 透彻了解 inlining 的里里外外(inlining 在大多数 C++ 程序中是编译期的行为;inline 函数是否真正 inline,取决于编译器;大部分编译器拒绝太过复杂(如带有循环或递归)的函数 inlining,而所有对 virtual 函数的调用(除非是最平淡无奇的)也都会使 inlining 落空;inline 造成的代码膨胀可能带来效率损失;inline 函数无法随着程序库的升级而升级)
31. 将文件间的编译依存关系降至最低(如果使用 object references 或 object pointers 可以完成任务,就不要使用 objects;如果能过够,尽量以 class 声明式替换 class 定义式;为声明式和定义式提供不同的头文件)
32. 确定你的 public 继承塑模出 is-a 关系(适用于 base classes 身上的每一件事情一定适用于 derived classes 身上,因为每一个 derived class 对象也都是一个 base class 对象)
Expand Down

0 comments on commit 2d6f80e

Please sign in to comment.