aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-05-08 13:15:45 +0530
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-05-08 13:15:45 +0530
commitff2b74d8d151b10383e6a3bee04766bfca5305e4 (patch)
treef48d0de011df21a366f079d4b6fd782442863b62 /src/main.cpp
parenta9797b80ca45cb40948ed0e682656c492c8a3639 (diff)
downloadsnek-ff2b74d8d151b10383e6a3bee04766bfca5305e4.tar.gz
snek-ff2b74d8d151b10383e6a3bee04766bfca5305e4.tar.bz2
snek-ff2b74d8d151b10383e6a3bee04766bfca5305e4.zip
Added vector operations to Point
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fe2c2ae..b8ea10f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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}
{}