1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

Point: Add operator+=, operator-=, and Point+Point

This commit is contained in:
Andreas Kling 2019-09-27 18:59:00 +02:00
parent 8b38518d0e
commit 57e73e4533

View file

@ -62,7 +62,22 @@ public:
}
Point operator-() const { return { -m_x, -m_y }; }
Point operator-(const Point& other) const { return { m_x - other.m_x, m_y - other.m_y }; }
Point& operator-=(const Point& other)
{
m_x -= other.m_x;
m_y -= other.m_y;
return *this;
}
Point& operator+=(const Point& other)
{
m_x += other.m_x;
m_y += other.m_y;
return *this;
}
Point operator+(const Point& other) const { return { m_x + other.m_x, m_y + other.m_y }; }
operator WSAPI_Point() const;
String to_string() const { return String::format("[%d,%d]", x(), y()); }