point.cpp 917 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "stdafx.h"
  2. #include "point.h"
  3. Point::Point( int px, int py )
  4. : x( px ),
  5. y( py )
  6. {
  7. }
  8. Point::Point( const Point& other )
  9. : x( other.x ),
  10. y( other.y )
  11. {
  12. }
  13. void Point::Offset( int xOffset, int yOffset )
  14. {
  15. x += xOffset;
  16. y += yOffset;
  17. }
  18. void Point::Offset( const Point& point )
  19. {
  20. x += point.x;
  21. y += point.y;
  22. }
  23. Point& Point::operator += ( const Point& other )
  24. {
  25. x += other.x;
  26. y += other.y;
  27. return *this;
  28. }
  29. Point& Point::operator -= ( const Point& other )
  30. {
  31. x -= other.x;
  32. y -= other.y;
  33. return *this;
  34. }
  35. Point operator + ( const Point& p1, const Point& p2 )
  36. {
  37. return Point( p1.x + p2.x, p1.y + p2.y );
  38. }
  39. Point operator - ( const Point& p1, const Point& p2 )
  40. {
  41. return Point( p1.x - p2.x, p1.y - p2.y );
  42. }
  43. bool operator == ( const Point& p1, const Point& p2 )
  44. {
  45. return ( ( p1.x == p2.x ) && ( p1.y == p2.y ) );
  46. }
  47. #include "stdafx.h"