Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 08 / NVector / Nvector.h
diff options
context:
space:
mode:
Commitdcb3e8f88bd16daa61735517bc0bc376c3c028d2 (patch)
Author
 Angel Dimitriev <angel_dimitriev@abv.bg>
2022-04-12 19:33:18 +0300
Committer
 GitHub <noreply@github.com>
2022-04-12 19:33:18 +0300
Files7d8a7f3c0231c1e93b196a8892562def676f1cf6 /Sem. 08/NVector/Nvector.h
Object-oriented_programming_FMI-dcb3e8f88bd16daa61735517bc0bc376c3c028d2.tar
Object-oriented_programming_FMI-dcb3e8f88bd16daa61735517bc0bc376c3c028d2.tar.gz
Object-oriented_programming_FMI-dcb3e8f88bd16daa61735517bc0bc376c3c028d2.zip
Parent7c1c723e3abba2d14b86efc0bd7bc0ce010397ac (diff)
Create Nvector.h
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..24e6ad6
--- /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);