summaryrefslogtreecommitdiff
path: root/include/ui/Point.h
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2009-05-26 17:44:57 -0700
committer Mathias Agopian <mathias@google.com> 2009-05-26 17:47:39 -0700
commit35801cea5f301c0e1d7a93b15a8f73f98e6b1033 (patch)
tree2cad208ad6212d912b6f3476c98c0873f8d56fd4 /include/ui/Point.h
parent7419ebc96fa5ae665dd4426dc5a4277c9ae1f325 (diff)
minor clean-up to Rect and Point.
- return "const" objects for overloaded operators to disallow constructs like: (a+b) = c; - don't return references to non-static members, it's not always safe. - Point.cpp was empty, so get rid of it
Diffstat (limited to 'include/ui/Point.h')
-rw-r--r--include/ui/Point.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/include/ui/Point.h b/include/ui/Point.h
index dbbad1ecc2..1653120a6d 100644
--- a/include/ui/Point.h
+++ b/include/ui/Point.h
@@ -31,12 +31,9 @@ public:
// because we want the compiler generated versions
// Default constructor doesn't initialize the Point
- inline Point()
- {
+ inline Point() {
}
-
- inline Point(int _x, int _y) : x(_x), y(_y)
- {
+ inline Point(int x, int y) : x(x), y(y) {
}
inline bool operator == (const Point& rhs) const {
@@ -57,8 +54,8 @@ public:
}
inline Point& operator - () {
- x=-x;
- y=-y;
+ x = -x;
+ y = -y;
return *this;
}
@@ -73,11 +70,13 @@ public:
return *this;
}
- Point operator + (const Point& rhs) const {
- return Point(x+rhs.x, y+rhs.y);
+ const Point operator + (const Point& rhs) const {
+ const Point result(x+rhs.x, y+rhs.y);
+ return result;
}
- Point operator - (const Point& rhs) const {
- return Point(x-rhs.x, y-rhs.y);
+ const Point operator - (const Point& rhs) const {
+ const Point result(x-rhs.x, y-rhs.y);
+ return result;
}
};