Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Style guide should be followed for all C++ code developed for WARG.

Functions

Naming and Brackets

Functions should use lower camel case in their names. There should be no spaces between the function name and the parameter list. The open curly-bracket must be on the same line as the function name, and must be separated from the parameter list by one space:

int hewwoThereFwend() { 
  return 0; 
}

Parameters

Pointers

The * in pointers must be separated on both sides by one space.

void hewwoThereFwend(string * fwendName) { ... }

NOTE: Moving forward, we will prefer to use reference parameters over pointers when passing by reference. It is a more C++ style of programming.

Reference Parameters

The & in reference parameters must be appended to the datatype of the parameter.

void hewwoThereFwend(string& fwendName) { ... }

We will prefer to use this C++ feature when passing values by reference from now on. To learn more about reference parameters, you can refer to the following links:

More than one Parameter

Parameters in a list must be separated by commas (obviously lol), but a space must separate a comma and a parameter:

void hewwoThereFwend(string& fwendName, string fwendTwoName) { ... }

If the parameter list is very long, creating a vertical list of parameters is acceptable too:

void hewwoThereFwend(string fwendOne,
                     string fwendOne,
                     string fwendOne,
                     string fwendOne,  )

Mathematics

Mathematical Operations

There should always be spaces around all mathematical operators. There should always be spaces between equal signs.

int b = (1 + 2 - 3) * 4/5.0 + 6 % 7;

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.