diff options
author | Sam Spilsbury <smspillaz@gmail.com> | 2010-01-22 00:16:27 +0800 |
---|---|---|
committer | Sam Spilsbury <smspillaz@gmail.com> | 2010-01-22 00:16:27 +0800 |
commit | 6c76a7cf9455e535a815a74bbebe261c8b9785f0 (patch) | |
tree | d206b773445dabb578cdbedb0bce02c3948a04cb /src | |
parent | c5e731bfd78ece8714470519a3bbb470f2d09001 (diff) | |
download | zcomp-6c76a7cf9455e535a815a74bbebe261c8b9785f0.tar.gz zcomp-6c76a7cf9455e535a815a74bbebe261c8b9785f0.tar.bz2 |
Add appropriate operator overloads to CompPoint
Diffstat (limited to 'src')
-rw-r--r-- | src/point.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/point.cpp b/src/point.cpp index c77e6cf..9b1f93f 100644 --- a/src/point.cpp +++ b/src/point.cpp @@ -1,5 +1,5 @@ /* - * Copyright © 2008 Dennis Kasprzyk + * Copyright © 2008 Dennis Kasprzyk * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without @@ -67,3 +67,34 @@ CompPoint::operator!= (const CompPoint &point) const { return !(*this == point); } + +CompPoint & +CompPoint::operator+= (const CompPoint &point) +{ + mX += point.mX; + mY += point.mY; + + return *this; +} + +CompPoint +CompPoint::operator+ (const CompPoint &rhs) const +{ + return CompPoint (mX + rhs.mX, mY + rhs.mY); +} + +CompPoint & +CompPoint::operator-= (const CompPoint &point) +{ + mX -= point.mX; + mY -= point.mY; + + return *this; +} + +CompPoint +CompPoint::operator- (const CompPoint &rhs) const +{ + return CompPoint (mX - rhs.mX, mY - rhs.mY); +} + |