Skip to content
Josh Klontz edited this page Jul 3, 2014 · 14 revisions

The most important rule is that new code should be consistent with the existing code around it. The rules below illustrate the preferred style when cleaning up existing inconsistently-styled code.

These rules are a work in progress and are subject to additions and (less likely) changes.

Structs & Classes

struct FooBar
{

};

Functions

int *fooBar(const int &x, int *y, int z)
{
    *y = x + z;
    return y;
}

Loops and Conditionals

Single-statement

for (int i=start; i<end; i++)
    foo();

Multiple-statement

for (int i=start; i<end; i++) {
    foo();
    bar();
}

Const

Use const whenever possible.

Clone this wiki locally