Added vector operations to Point

This commit is contained in:
2024-05-08 13:15:45 +05:30
parent a9797b80ca
commit ff2b74d8d1

View File

@@ -45,11 +45,31 @@ struct Point
{
int x, y;
bool operator==(const struct Point &p) const
bool operator==(const Point &p) const
{
return x == p.x && y == p.y;
}
Point operator+(const Point &p) const
{
return {x + p.x, y + p.y};
}
Point operator-(const Point &p) const
{
return {x - p.x, y - p.y};
}
Point operator*(const Point &p) const
{
return {x * p.x, y * p.y};
}
Point operator*(int m) const
{
return {x * m, y * m};
}
Point() : x{0}, y{0}
{}