...
Parameter names
Parameter names should be in camel case follow the same conventions as written in the Variables
section.
Pointers
The *
in pointers must be separated on both sides by one space.
Code Block | ||
---|---|---|
| ||
void hewwoThereFwend(string * fwendNamefwend_name) { ... } |
NOTE: Moving forward, we will prefer to use reference parameters over pointers when passing by reference. It is a more C++ style of programming.
...
Code Block |
---|
void hewwoThereFwend(string& fwendNamefwend_name) { ... } |
We will prefer to use this C++ feature when passing values by reference. To learn more about reference parameters, you can refer to the following links:
...
Code Block | ||
---|---|---|
| ||
void switchFwendName(string& fwendNamefwend_name, string newFwendNamenew_fwend_name) { ... } |
If the parameter list is very long, creating a vertical list of parameters is acceptable too. Just ensure each parameter starts in the same column so as to ensure readability.
Code Block | ||
---|---|---|
| ||
void hewwoThereFwend(string fwendOnefwend_one, string fwendTwofwend_two, string fwendTweefwend_three, string fwendFourfwend_four, string fwendFivefwend_five) { ... } |
Commenting
All function declarations must have a comment above describing its purpose, parameters, and returned value. Pay notice to the spacing on the *
and the /**
that opens the comment
Code Block | ||
---|---|---|
| ||
/** * This function switches the friend's name with a new name * * @param fwendNamefwend_name -> reference pointing to the friend's name * @param newFwendNamenew_fwend_name -> value of the friend's new name * * @return none */ void switchFwendName(string& fwendNamefwend_name, string newFwendNamenew_fwend_name); |
Data Structures
...
Classes
Classes use PascalCase
Structs
Enums
We use PascalCase for enunms, and the constants will use all caps with underscores separating words. Additionally, the first constant should have a = 0
appended to it.
Code Block | ||
---|---|---|
| ||
enum EnumOne {HEWWO = 0, THERE, MY, FWEND};
// If there are a lot of terms, you can split them on multiple lines with one constant per line
enum EnumTwo {
HEWWO = 0,
THERE,
MY,
FWEND,
YOU,
AWRE,
AMAZING
}; |