All codes in this course are expected to have been written using ourhouse style, which will try to follow the C++ core guidelines as closely as possible (or at least, the easier sections while we are building up your confidence). Another rather different set commonly used is the google C++ style. If you are to become a professional coder–and quite a few studentstaking this course do–one of the important prerequistes you will be expected to stick to is a house style: that makes it easier for you to know what is right and wrong, and for us to explain the marks!
Let me highlight a few parts of section NL here:
speed_of_light_in_vacuum
speed_of_light_in_vacuum
and
calculate_tax()
.
{}
and indentationWe will use curly braces in a "medium compact" notation where an opening brace occurs on the same line as the statement it follows, apart from the case of a function or a class, where we shall put it on a new line. If the next statement after the closing brace is part of the same expression (as in the case of, e.g. an else
) this will be on the same line as a closing brace. Statements will be rigourously indented, i.e., each nested block will indent the same number of spaces (see NL.4).
We normally will use a namespace by the name resolution operator,e.g.,
std::cout<<i;
and not using namespace std;cout <<i;
The reason for this will become clear when we discuss namespaces in detail, but see SF.6.
When introducing new concepts, we shall attempt to introduce the relevant parts of the housestyle (again, by highlighting the relevant section of the style guide)