(Contents Preamble...6 Chapter 1 File Structure...111.1 Copyright and Version Notices...111.2 Structure of Header Files...121.3 Structure of Definition Files...131.4 Effects of Header Files...131.5 Directories Structure...14 Chapter 2 Layout of Programs...152.1 Blank Lines...152.2 Code Lines...162.3 Spaces within Code Lines...172.4 Alignment...182.5 Long Line Splitting...192.6 Modifiers Orientation... 192.7 Notes... 202.8 Layout of Classes... 21 Chapter 3 Naming Rules... 223.1 Common Rules... 223.2 Simple Windows Using Program Naming Rules... 233.3 Simple Unix Using Program Naming Rules...25 Chapter 4 Expressions and Basic Sentences...264.1 Precedence of Operators...264.2 Compound Expressions...274.3 If Sentences...274.4 Efficiency of Looping Sentences...294.5 For Sentences Loop control variables... 304.6 switch sentences... 304.7 goto sentences... 31 Chapter 5 constants... 335.1 Why constants are needed... 335.2 Contrast between const and #define... 335.3 Constant definition rules... 335.4 Constants in Classes...34 Chapter 6 Function Design...366.1 Rules for Parameters...366.2 Rules for Return Values...376.3 Rules for Internal Implementation of Functions...396.4 Other Recommendations...406.5 Using Assertion ...416.6 Comparison of Citations and Pointers...42 Chapter 7 Memory Management...447.1 Memory Allocation Methods...447.2 Common Memory Errors and Their Countermeasures...447.3 Comparison of Pointers and Arrays...457.4 Pointers How do parameters pass memory?...477.5 What about free and delete pointers?...507.6 Will dynamic memory be automatically released? Still need new/delete?...527.9 How to deal with memory exhaustion?...537.10 The key to using malloc/free...547.11 The key to using new/delete...557.12 Some experiences...56 Chapter 8 Advanced features of C functions... 578.1 The concept of function overloading... 578.2 Overloading, overriding and hiding of member functions... 608.3 Missing values ??of parameters... 638.4 Operator overloading... 648.5 Function inlining... .658.6 Some experiences... 68 Chapter 9 Class structure functions, destructors and assignment functions... 699.1 The origin of structure functions and destructors... 699.2 The initialization table of structure functions... 709.3 Structure and Destructive order ...729.4 Example: Structure function and destructor of class String...729.5 Don't underestimate copy structure function and assignment function...739.6 Example: Copy structure function and assignment function of class String...739.7 Ways to get away Managing copy structure functions and assignment functions... 759.8 How to implement the basic functions of a class in a derived class... 759.9 Some experiences... 77 Chapter 10 Inheritance and composition of classes... 7810.1 Inheritance... 7810.2 Composition ...80 Chapter 11 Other Programming Experiences...8211.1 Using const to Improve the Robustness of Functions...8211.2 Improving Program Efficiency...8411.3 Some Helpful Suggestions...85 References...87 Appendix A: C /C Code Review Form...88 Appendix B: C /C Test Questions...93 Appendix C: Answers and Grading Standards for C /C Test Questions...97
High Quality C Programming Guide.doc)