Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 08 / Nvector / Nvector.h
diff options
context:
space:
mode:
Commitce24f073c5e946b5bad600fca1ca8808657ee9ce (patch)
Author
 angeld55 <angel_dimitriev@abv.bg>
2021-04-16 15:50:04 +0300
Committer
 angeld55 <angel_dimitriev@abv.bg>
2021-04-16 15:50:04 +0300
Files948e5f8ef602b7eff3822b289ce5c0ab16ba4bf2 /Sem. 08/Nvector/Nvector.h
Object-oriented_programming_FMI-ce24f073c5e946b5bad600fca1ca8808657ee9ce.tar
Object-oriented_programming_FMI-ce24f073c5e946b5bad600fca1ca8808657ee9ce.tar.gz
Object-oriented_programming_FMI-ce24f073c5e946b5bad600fca1ca8808657ee9ce.zip
Parentb233a370168ea6239f8233a299460f8f55cbf3c7 (diff)
added sem 8
1 files changed, 52 insertions, 0 deletions
-rw-r--r--Sem. 08/Nvector/Nvector.h52
diff --git a/Sem. 08/Nvector/Nvector.h b/Sem. 08/Nvector/Nvector.h
new file mode 100644
index 0000000..745a844
--- /dev/null
+++ b/Sem. 08/Nvector/Nvector.h
@@ -0,0 +1,52 @@
+#pragma once
+#include <iostream>
+
+class Nvector
+{
+private:
+ int* data;
+ size_t size;
+
+ void copyFrom(const Nvector& other);
+ void free();
+
+public:
+ Nvector(size_t size);
+
+ Nvector(const Nvector& other);
+ Nvector& operator=(const Nvector& other);
+ ~Nvector();
+
+ Nvector& operator+=(const Nvector& other);
+ Nvector& operator-=(const Nvector& other);
+
+ Nvector& operator*=(size_t scalar);
+
+ int& operator[](size_t); //get set
+
+ int operator[](size_t) const; // get
+
+ void print();
+
+ size_t operator~() const;//ize;
+
+ friend std::ostream& operator<<(std::ostream& os, const Nvector& v);
+ friend std::istream& operator>>(std::istream&, Nvector& v);
+};
+
+const Nvector operator+(const Nvector& lhs, const Nvector& rhs);
+const Nvector operator-(const Nvector& lhs, const Nvector& rhs);
+
+const Nvector operator*(const Nvector& lhs, size_t scalar);
+//So it could be commutative. Is there a better way?
+const Nvector operator*(size_t scalar, const Nvector& lhs);
+
+//are parallel
+bool operator||(const Nvector& lhs, const Nvector& rhs);
+
+
+//scalar product
+size_t operator%(const Nvector& lhs, const Nvector& rhs);
+
+//are perpendicular
+bool operator||(const Nvector& lhs, const Nvector& rhs); \ No newline at end of file