about summary refs log tree commit diff
path: root/usth/ICT2.2/labwork/3/C++/vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'usth/ICT2.2/labwork/3/C++/vector.h')
-rw-r--r--usth/ICT2.2/labwork/3/C++/vector.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/usth/ICT2.2/labwork/3/C++/vector.h b/usth/ICT2.2/labwork/3/C++/vector.h
new file mode 100644
index 0000000..8433e79
--- /dev/null
+++ b/usth/ICT2.2/labwork/3/C++/vector.h
@@ -0,0 +1,17 @@
+class Vector
+{
+public:
+  int x;
+  int y;
+
+  Vector (int ex, int why) : x {ex}, y {why} {}
+  Vector () : x {0}, y{0} {}
+
+  Vector& operator+= (Vector v) { x += v.x, y += v.y; return *this; }
+  Vector& operator-= (Vector v) { x -= v.x, y -= v.y; return *this; }
+  Vector& operator*= (Vector v) { x *= v.x, y *= v.y; return *this; }
+};
+
+Vector operator+ (Vector, Vector);
+Vector operator- (Vector, Vector);
+Vector operator* (Vector, Vector);