Some time ago I read the Google C/C ++ programming style and extract some important points. Please give us some advice.
For the sake of clarityGoogle C ++Programming specifications:
Pascal case: When an identifier is composed of two or more words, no other symbols are added between words, and each word must be capitalized, such as pascalcase.
Camel case: When an identifier is composed of two or more words, no other symbols are added between words. The first word starts with lowercase, And the other words start with uppercase. For example, camelcase.
Unix/LinuxVariable naming method: WhenProgramWhen it is composed of two or more words, the words start with lowercase and are connected.
Below isGoogle C ++Some content of programming specifications:
I. Naming
1) Common variables:LinuxNaming rules. For example:StringTable_name;
2) constants:K +Pascalcase. For example, const int kdayinaweek = 7;
3) class private members: Linux naming rules+_. For example:IntParament_count _;
4) Name of a common function: pascalcase. For example:Addtableentry ().
5) storage functions:LinuxNaming method. For example:
Int num_entries () const {return num_entries _};
Void set_num_entries () {int num_entries };
6) enumeration: The value is a word in uppercase. Words are separated by underscores. For example, my_enum_value
7) Class Name and structure Name:Pascalcase
Ii. Function Parameters
The input parameter is money, and the output parameter is later.
Iii. Sorting of header files
CSystem header file
C ++System header file
Other library header files
Header files in this project
Iv. File comments
1. creator of Creation Time
2. Modify the time modifier to modify the function list.
3. In the header file, the role of this class is first defined, and the function usage is briefly described.
V. Other conventions
1, Each line should not exceed80Characters, excluding long paths or header file protection;
2, Set the editorTabConvert to space, preferably4Space;
3And empty loop body usage{},ContinueInstead of a semicolon;
4Do not use the Hungarian naming method.
the most important thing is to be consistent with the programming style of your team, even if your team's programming style conflicts with the one described above.