Every C++ programmer has files of useful functions that he or she uses in almost every project. Many of my examples include a file called util.h, which is listed in this appendix.
Util.h follows a simple coding style with only a few basic rules:
1. Names should be chosen to reflect their interpretation. Type names begin with uppercase letters, function, parameter, and variable names begin with lower case letters, and macro names only use uppercase letters.
2. Format should reflect program structure. Indentation levels should reflect nesting levels, blank lines should separate logical tasks, and opening and closing curly braces should be aligned.
3. Comments shouldn't be overdone or underdone. Comments should be literate. Each file begins with a comment that at least contains the author's name. Each function begins with a comment that tells the function's purpose. Non-obvious entry, exit, and exception conditions should be mentioned. Remarks about algorithm can be included if they're helpful.
Many universities and companies have their own style guidelines, which readers are welcome to use in place of mine, but some style guideline must be followed. There are several proposals for standard C++ style guidelines, which readers may also use.