In comments, I usually say either "this" or "ourself" (because I generally write comments in first-person plural, but "ourselves" is too weird when there's only one object).
In documentation, I say "the <whatever>
". If that's ambiguous (because the function takes another one as a parameter, for instance), I say "this object", or "this <whatever>
". <whatever>
is either the class name, or some other term used in the documentation to explain what the class represents.
/**
* An utterly useless write-only counter, with arbitrary initial value.
*/
class Counter {
unsigned int count;
public:
/**
* Increments the counter
*/
Counter &operator++() {
// We need to add 1 to ourself. I found a snippet online that does it:
++count;
// return ourself
return *this;
}
/**
* Adds together this counter and "other".
*/
Counter operator+(const Counter &other) const {
Counter result;
// new count is our count plus other count
result.count = count + other.count;
return result;
}
};