This is an article written on January 23, 1996, now has 9 years, very old, may not be able to keep up with the situation, but some things are still worthy of the current developer learning, I translated this text for the reader's reference only.
Original link: http://www.gamedev.net/reference/articles/article708.asp
File
The header file has an ". h" suffix. Header files contain classes (class), structs (struct), and Union (Union) declarations, enumerations (enum) declarations, #define, typedef.
The implementation file has a ". CC" (UNIX) or ". cpp" (Windows, DOS) suffix. The implementation file includes the implementation of functions and methods.
Arrange a header in the header file and source code file. Headers can contain title, author, date, and some engineering information, such as this file is in conjunction with the entire project.
Some names
Generic C + + character name:
(Note: These are all symbols of the English original, there is no completely standardized Chinese vocabulary corresponding, so the following translation is only personal advice)
{ |
Open brace, open curly left curly brace |
} |
Close brace, close curly right curly brace |
( |
Open parenthesis, open paren left parenthesis |
) |
Close parenthesis, close paren right parenthesis |
[ |
Open Bracket left Bracket |
] |
Close Bracket Closing Bracket |
. |
period, dot period, dot |
! |
Exclamation point, bang, not exclamation mark, no |
| |
Bar, Vertical-bar, or, Or-bar (actually a "vertical virgule") vertical bar, bitwise OR |
& |
Ampersand, and, reference, ref and, bitwise with, reference, take address |
* |
Asterisk, multiply, star, pointer asterisk, multiplication, stars, pointers |
/ |
Slash, divide Slash, division |
// |
Slash-slash, comment Double slash, annotation character |
# |
Pound (macro: #, referring to the macro technique of converting symbols to strings) |
\ |
Backslash, (sometimes "escape") backslash, (sometimes as an escape character) (another: line continuation) |
~ |
Tilde by Bitwise counter |
The basic type "char" is usually pronounced "charcoal." The first syllable. Sometimes read "care" or "car."
Name and typesetting
Name of the naming convention
Interspersed_underscores Middle Underline
Lowercasemixedcapital Lowercase mixed (first letter) uppercase;
Capitalmixedcapital (first letter) uppercase mixed (first letter) uppercase;
All_uppercase ALL Caps
Application of the naming convention
Enumeration_item_name enumeration, lower case underlined;
VariableName variable, lowercase prefix plus first letter uppercase suffix;
TypeName, ClassName, methodname () type name, class name, method name, first letter uppercase prefix;
unixfilename.cc unix/linux FileName: Capitalize the first letter of each word;
Dosfn.cpp windows/dos filename: all lowercase;
POUND_DEFINES macro definition, all uppercase;
Self-documentation code (i.e., no documentation, just the source code file with comments and code descriptions)
Use full spelling for each name in the program.
Avoid direct use of numbers (Magic number)
Numeric constants other than 0 (sometimes including 1) are not allowed. Use a constant variable or a macro definition (#defines).
Blank
Space (by the space bar to get);
New lines (press ENTER to get);
tab (8 spaces instead);
Blank and typesetting
After the left curly brace, indent 4 spaces per line until the corresponding right curly brace appears.;
If if, while, or for the following is not followed by a curly brace, the next line indents two spaces;
The statement at the end of the colon, indented two spaces (public, case) in reverse;
The reserved word (if, else, class, struct) should be preceded by 1 spaces unless it has been indented because of new lines or special punctuation;
The operator and the comparison character must have a space before and after it (except!);
Pointer variable (&,*) Declaration of time to add a space before and after;
Pointer variable (&,*) in the expression, preceded (not behind) to add a space llowed);
Add a space after the left parenthesis;