You may use 2 or 4 space indentation. Choose one and be consistent.
You may either place your brackets at the end of the line or the beginning of the next line. Choose one and be consistent.
Prefer to use curly brackets when they are optional to avoid bugs:
int i;
for (i = 0; i < max; ++i); // bug waiting to happen
if (i == j)
return i;
For naming only, we will be following the Google C++ Style Guide for Naming.
Your names should always be meaningful.
Classes and struct names: CapitalizedLikeThis
, Point
or PlayerQueue
Variable names: capitalized_like_this
, my_var
or num
Class member variables: private variables should have a single trailing _
: x_
or secret_data_
Function names: static, helper, and “regular” functions are NamedLikeThis
, double Distance(const Point &p) const
or void CalcArea(const int &width, const int &height, int *area)
Accessor functions are named like variables, int get_x() const
You do not need one class per file, but your namespaces should make semantic sense.
You must comment your code. This includes file comments, function comments, and in-line comments.
File comments: should be used to identify yourself, give a brief description of what the program does, and how to run it.
/**
Felix Muzny
Homework 1
This program is a fun and exciting two-player maze game.
It takes one command-line argument, the path to the maze file.
*/
Function comments: Should provide a brief description of what the function does, what parameters it takes, and what it returns. A user should know how to run the function using only your comment and the function header.
/**
Returns the volume of a sphere with the specified radius.
@param radius The radius of the circle.
@return The volume of the sphere.
*/
double Volume(double radius);
In-line comments: Should not repeat your code, but should clarify complicated portions with what they are intended to do.