The general rule for .h vs. .C comments is that .h are for the user of the class (they don't necessarily care how the function is implemented, they just want to be able to call the function; they need to know what it does, what it returns, and what to pass to it). Comments in .C files are for someone reading the implementation of the class (in addition to the .h file comment info, you may add more information about the algorithm used to implement the function). I tend to create the .h file first, add all comments, then copy the .h to the .C (now I have all the function comments for the function implementations that will be in the .C and I only need to add additional comments about implementation).
When commenting stick to a particular style. For example:
//
// public method function: getRadius
// input: none
// returns: the radius of the circle in inches
//
float SemiCircle::getRadius() {
return _radius;
}
//
// public method function: flipOrRotate
// rotates the semi-circle by the given degree
// and/or flips it over its radius
//
// deg: the number of degrees to rotate the semi-circle
// positve value will rotate clockwise
// negative value will rotate counter-clockwise
// flip: if 1, flip the semi-circle over its radius
// before rotating
// returns: no return value
//
void SemiCircle::flipOrRotate(float deg, char flip) {
...
class SemiCircle : public Shape {
};
class SemiCircle : public Shape {
public:
float getRadius();
double area();
void flipOrRotate(float deg, char flip);
bool inRadians;
};
class SemiCircle : public Shape {
public:
float getRadius();
double area();
void flipOrRotate(float deg, char flip);
bool inRadians;
private:
void _convert_to_radians();
float _radius;
};
class SemiCircle : public Shape {
public:
float getRadius();
double area();
bool isInRadians() { return _in_radians; } // accessor method
void setRadians(bool on); { _in_radians = on; } // modifier
private:
void _convert_to_radians();
float _radius;
bool _in_radians; // private data member
};
minibase_. Macro definitions should
begin with MINIBASE_.