C++ Coding Standard Specification - CERN
C++ Coding Standard Specification - CERN
C++ Coding Standard Specification - CERN
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>C++</strong> <strong>Coding</strong> <strong>Standard</strong><br />
<strong>Specification</strong><br />
4 Style Version/Issue: 1.1/5<br />
SC3<br />
In the header file, provide a comment describing the use of a declared function and attributes, if<br />
this is not completely obvious from its name.<br />
Example:<br />
class Point {<br />
public:<br />
// Perpendicular distance of Point from Line<br />
Number distance (Line);<br />
}<br />
the comment includes the fact that it is the perpendicular distance.<br />
Source<br />
Status<br />
CXX-10<br />
Common<br />
SC4<br />
In the implementation file, above each method implementation, provide a comment describing<br />
what the method does, how it does it (if not obvious), preconditions and postconditions.<br />
The code in a method will be much easier to understand and maintain if it is well explained in<br />
an initial comment.<br />
SC5<br />
All #else and #endif directives should carry a comment that tells what the corresponding #if<br />
was about if the conditional section is longer than five lines.<br />
The number five is obviously a reasonable arbitrary convention, in order to make the item<br />
objective and checkable.<br />
Example:<br />
#ifndef GEOMETRY_POINT_H<br />
#define GEOMETRY_POINT_H<br />
class Point {<br />
public:<br />
Point(Number x, Number y);<br />
// Create from (x,y)<br />
Number distance(Point point) const; // Distance to a point<br />
Number distance(const Line & line) const; // Distance from a line<br />
void translate(const Vector & vector); // Shift a point<br />
};<br />
#endif // GEOMETRY_POINT_H<br />
Source<br />
Status<br />
CXX-60, R49<br />
Common<br />
page 38<br />
FINAL