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
diff --git a/include/ui/Point.h b/include/ui/Point.h
index dbbad1e..1653120 100644
--- a/include/ui/Point.h
+++ b/include/ui/Point.h
@@ -31,12 +31,9 @@
// 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 @@
}
inline Point& operator - () {
- x=-x;
- y=-y;
+ x = -x;
+ y = -y;
return *this;
}
@@ -73,11 +70,13 @@
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;
}
};