资源说明:C++ Hackers Guide.pdf
Table of Contents
Real World Hacks................................................................................................9
Hack 1: Make Code Disappear..........................................................................10
Hack 2: Let Someone Else Write It...................................................................12
Hack 3: Use the const Keyword Frequently For Maximum Protection.............12
Hack 4: Turn large parameter lists into structures..........................................14
Hack 5: Defining Bits.........................................................................................16
Hack 6: Use Bit fields Carefully........................................................................18
Hack 7: Documenting bitmapped variables......................................................19
Hack 8: Creating a class which can not be copied............................................21
Hack 9: Creating Self-registering Classes.........................................................22
Hack 10: Decouple the Interface and the Implementation...............................25
Hack 11: Learning From The Linux Kernel List Functions...............................27
Hack 12: Eliminate Side Effects........................................................................29
Hack 13: Don't Put Assignment Statements Inside Any Other Statements......30
Hack 14: Use const Instead of #define When Possible.....................................31
Hack 15: If You Must Use #define Put Parenthesis Around The Value.............32
Hack 16: Use inline Functions Instead of Parameterized Macros Whenever Possible........................................................................................................33
Hack 17: If You Must Use Parameterized Macros Put Parenthesis Around The arguments....................................................................................................34
Hack 18: Don't Write Ambiguous Code.............................................................34
Hack 19: Don't Be Clever With the Precedence Rules......................................35
Hack 20: Include Your Own Header File...........................................................36
Hack 21: Synchronize Header and Code File Names.......................................37
Hack 22: Never Trust User Input......................................................................38
Hack 23: Don't use gets.....................................................................................40
Hack 24: Flush Debugging................................................................................41
Hack 25: Protect array accesses with assert....................................................42
Hack 26: Use a Template to Create Safe Arrays...............................................45
Hack 27: When Doing Nothing, Be Obvious About It........................................46
Hack 28: End Every Case with break or /* Fall Through */...............................47
Hack 29: A Simple assert Statements For Impossible Conditions....................47
Hack 30: Always Check for The Impossible Cases In switches.........................48
Hack 31: Create Opaque Types (Handles) Which can be Checked at Compile Time.............................................................................................................49
Hack 32: Using sizeof When Zeroing Out Arrays..............................................51
Hack 33: Use sizeof(var) Instead of sizeof(type) in memset Calls....................51
Hack 34: Zero Out Pointers to Avoid Reuse......................................................53
Hack 35: Use strncpy Instead of strcpy To Avoid Buffer Overflows.................54
Hack 36: Use strncat instead of strcat for safety..............................................55
......
......
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。