| | |
Summary:
Style in C++
Basic principles
Readability is the most important attribute of style
Choose good names. The most direct way of explaining what a program is about is by selecting good
names for variables, types, methods. Finding a good name is sometimes challenging. Often it is a
question of understanding. With understanding comes good names, and vice versa.
Code so that changes will be easier.
Formatting
1. Indent to show organizational structure of code. Four or less spaces is a good indentation amount.
Any larger and you risk lots of line wrapping.
2. Blank lines improve readability by setting off sections of code that are logically related.
3. Two blank lines should always be used in the following circumstances:
a. Between sections of a source file
b. Between class and interface definitions
4. One blank line should always be used in the following circumstances:
|