Просмотр исходного кода

Add == and != operators to Rectangle class

Nur Monson 12 лет назад
Родитель
Сommit
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; }
 
+			bool operator==(const Rectangle& rect) const;
+			bool operator!=(const Rectangle& rect) const { return !(*this == rect); }
+
 			/**
 			* X position
 			*/									

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

@@ -44,3 +44,11 @@ Rectangle Rectangle::Clipped(const Rectangle& rect) const
 
 	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;
+}