This is an old revision of the document!
Code style
- Code style for Eclipse:code style
- Use single blank lines
- Use doxygen (java or c++)
- Always use downcase in namespace
- Space after semicolon in for-loops etc.
- Space before and after assignment operators
… and follow the example below …
namespace metno {
const int DEFAULT_NUMBER = 1;
/**
* A sample source file for the code formatter preview
*/
class Point {
public:
/**
* @param xc bla bla
*/
Point(double xc, double yc) : x(xc), y(yc) { }
Point(double yc) : y(yc)
{
if (true) {
} else if (false) {
}
for (int i = 0; i < yc; ++i) { ///< space after ;
int j = 0;
}
}
/**
* Description of distance
*/
double distance(const Point& other) const;
int minParam;
double x; ///< a doxygen comment on dx
double y;
char *hello;
Point& p;
/// Enum description
enum MyEnum {ONE, TWO, THREE};
};
double Point::distance(const Point& other) const {
double dx = x - other.x;
LOG4CXX_DEBUG(logger,"");
double dy = y - other.y; // comment
return sqrt(dx * dx + dy * dy);
}
} // end namespace metno