Summary: Style in C++
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, procedures. If I'm trying to write some new code, and I can't figure out a good name for a class or
method, I'll often be stuck until I have something. Many times, I find that the reason I can't pick a good name is that I
don't understand enough about what I'm trying to say; with understanding comes good names, and vice versa.
Code so that changes and understanding will be easier.
1. Indent to show organizational structure of code. Four spaces is a good indentation amount. Any larger and you
risk needs lots of line wrapping.
2. Blank lines improve readability by setting off sections of code that are logically related.
3. Do not place multiple statements on the same line.
4. Do not exceed 80 characters on a line. Indent continuation lines.
5. One declaration per line is recommended since it encourages commenting.
6. Comments should always use // so that /* and */ can be used to comment out whole sections of code.