《More Effective C++》35个条款
2006-06-26 14:38
549 查看
Basics:
1. Distinguish between pointers and references
2. Prefer C++-style casts
3. Never treat arrays polymorphically
4. Avoid gratuitous default constructors
Operators:
5. Be wary of user-defined conversion functions
6. Distinguish between prefix and postfix forms of increment and decrement operators
7. Never overload ?||, or,
8. Understand the different meaning of new and delete
Exceptions:
9. Use destructors to prevent resource leaks
10. Prevent resource leaks in constructors
11. Prevent exception from leaving destructors
12. Understand how throwing an exception differs from passing a parameter or calling a virtual funcation
13. Catch exceptions by reference
14. Use exception specifications judiciously
15. Understand the costs of exception handling
Efficiency:
16.Remember the 80-20 rule
17. Consider using lazy evaluation
18. Amortize the cost of excepted computations
19. Understand the origin of temporary objects
20. Facilitate the return value optimization
21. Overload to avoid implicit type conversations
22. Consider using op= instead of stand-alone op
23. Consider alternative libraries
24. Understand the costs of virtual funcations, multiple inheritance, vitual base class and RTTI
25. Virtualizing constructors and non-member functions
26. limiting the number of objects of a class
27. Requiring or prohibiting heap-based objects
28. Smart pointers
29. Reference counting
30. Proxy classes
31. Making functions virtual with respect to more than one object
Miscellany:
32. Program in the future tense
33. Make non-leaf classes abstract
34. Understand how to combine C++and C in the same program
35. Familiarize yourself with the language standard
1. Distinguish between pointers and references
2. Prefer C++-style casts
3. Never treat arrays polymorphically
4. Avoid gratuitous default constructors
Operators:
5. Be wary of user-defined conversion functions
6. Distinguish between prefix and postfix forms of increment and decrement operators
7. Never overload ?||, or,
8. Understand the different meaning of new and delete
Exceptions:
9. Use destructors to prevent resource leaks
10. Prevent resource leaks in constructors
11. Prevent exception from leaving destructors
12. Understand how throwing an exception differs from passing a parameter or calling a virtual funcation
13. Catch exceptions by reference
14. Use exception specifications judiciously
15. Understand the costs of exception handling
Efficiency:
16.Remember the 80-20 rule
17. Consider using lazy evaluation
18. Amortize the cost of excepted computations
19. Understand the origin of temporary objects
20. Facilitate the return value optimization
21. Overload to avoid implicit type conversations
22. Consider using op= instead of stand-alone op
23. Consider alternative libraries
24. Understand the costs of virtual funcations, multiple inheritance, vitual base class and RTTI
25. Virtualizing constructors and non-member functions
26. limiting the number of objects of a class
27. Requiring or prohibiting heap-based objects
28. Smart pointers
29. Reference counting
30. Proxy classes
31. Making functions virtual with respect to more than one object
Miscellany:
32. Program in the future tense
33. Make non-leaf classes abstract
34. Understand how to combine C++and C in the same program
35. Familiarize yourself with the language standard
相关文章推荐
- 读《More Effective C++35个改善编程与设计的有效方法》之条款3:绝对不要以多态方式处理数组
- More Effective C++(条款15:了解异常处理(exception handling)的成本)
- MoreEffective C++(条款16:谨记80-20法则)
- More Effective C++ (条款21:利用重载技术避免隐式类型转换)
- More Effective C++ 条款24 了解virtual function,multiple inheritance,virtual base classes,runtime type id
- More Effective C++ 条款3 绝对不要以多态(polymorphically)方式处理数组
- 《More Effective C++》条款27:如何让类对象只在栈(堆)上分配空间?
- More Effective C++(条款7:千万不要重载&&,||,和,操作符)
- More Effective C++(条款9:利用destructors避免泄露资源)
- 《More Effective C++》条款27:如何让类对象只在栈(堆)上分配空间?
- More Effective C++ 条款27(下)
- [More Effective C++]条款二十:协助完成返回值优化
- 《More Effective C++》条款26:限制某个Class所能产生的对象数量
- more effective c++使用条款(一)—— 基础议题/运算符
- [More Effective C++]条款十九:理解临时对象的来源
- More Effective C++ 条款35 让自己习惯于标准C++ 语言
- More Effective C++ 条款21 利用重载技术避免隐式类型转换
- More Effective C++ 条款23 考虑使用其他程序库
- More Effective C++ 条款7 千万不要重载&&,||和,操作符
- More Effective C++ 条款8 了解各种不同意义的new和delete