Add unary minus operator for Point

This commit is contained in:
Dmitry Marakasov 2015-07-03 22:21:02 +03:00
parent 1001bf8fa2
commit 47f0263ca3
2 changed files with 12 additions and 0 deletions

View File

@ -66,6 +66,10 @@ Point& Point::SetY(int ny) {
return *this;
}
Point Point::operator-() const {
return Point(-x, -y);
}
Point Point::operator+(const Point& other) const {
return Point(x + other.x, y + other.y);
}

View File

@ -156,6 +156,14 @@ public:
////////////////////////////////////////////////////////////
Point& SetY(int ny);
////////////////////////////////////////////////////////////
/// \brief Get point's memberwise negation
///
/// \returns New Point representing memberwise negation
///
////////////////////////////////////////////////////////////
Point operator-() const;
////////////////////////////////////////////////////////////
/// \brief Get point's memberwise addition with another point
///