The recommendations provided by the C Coding Style guidelines also apply in C++: give your {files,variables,classes,namespaces,etc} relevant (English) names.
Additionally, the following rules apply:
LikeThis
.
Class should be named in mixed case; for instance Exp
,
StringExp
, TempMap
, InterferenceGraph
etc. This
also applies to class templates.
public
members like_this
. No upper case
letters, and words are separated by an underscore.
private
and protected
members
like_this_
. It is extremely convenient to have a special
convention for private and
protected members: you make it clear to the reader, you avoid gratuitous
warnings about conflicts in constructors, you leave the “beautiful”
name available for public members etc. We used to write
_like_this
, but this goes against the standard (see Stay out of reserved names).
For instance, write:
class IntPair { public: IntPair (int first, int second) : first_ (first), second_ (second) { } protected: int first_, second_; }
LikeThis
per files
like-this.*. Each class LikeThis
is implemented in a
single set of file named like-this.*. Note that the mixed case
class names are mapped onto lower case words separated by dashes.
There can be exceptions, for instance auxiliary classes used in a single place do not need a dedicated set of files.
likethis
.
This section is incomplete and you must follow the guidelines specified in the section Name Conventions of Tiger Assignment.