فهرست منبع

Add == and != operators to Rectangle class

Nur Monson 12 سال پیش
والد
کامیت
b20c87b80f
2فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 3 0
      Core/Contents/Include/PolyRectangle.h
  2. 8 0
      Core/Contents/Source/PolyRectangle.cpp

+ 3 - 0
Core/Contents/Include/PolyRectangle.h

@@ -73,6 +73,9 @@ namespace Polycode {
 			*/
 			*/
 			Number maxY() const { return y + h; }
 			Number maxY() const { return y + h; }
 
 
+			bool operator==(const Rectangle& rect) const;
+			bool operator!=(const Rectangle& rect) const { return !(*this == rect); }
+
 			/**
 			/**
 			* X position
 			* X position
 			*/									
 			*/									

+ 8 - 0
Core/Contents/Source/PolyRectangle.cpp

@@ -44,3 +44,11 @@ Rectangle Rectangle::Clipped(const Rectangle& rect) const
 
 
 	return result;
 	return result;
 }
 }
+
+bool Rectangle::operator==(const Rectangle& rect) const
+{
+	if( x == rect.x && y == rect.y && w == rect.w && h == rect.h)
+		return true;
+
+	return false;
+}