Add add/assign operator to point

This commit is contained in:
Danny Robson 2011-09-07 21:51:13 +10:00
parent 91daeb332f
commit d6f0fd956c
2 changed files with 11 additions and 0 deletions

View File

@ -43,3 +43,12 @@ point::manhattan (const point &other) const {
return fabs (x - other.x) +
fabs (y - other.y);
}
point&
point::operator+= (const point &rhs) {
x += rhs.x;
y += rhs.y;
return *this;
}

View File

@ -29,6 +29,8 @@ namespace util {
double distance (const point &) const;
double manhattan (const point &) const;
point& operator+= (const point&);
};
}