From dcb3e8f88bd16daa61735517bc0bc376c3c028d2 Mon Sep 17 00:00:00 2001 From: Angel Dimitriev Date: Tue, 12 Apr 2022 19:33:18 +0300 Subject: Create Nvector.h --- Sem. 08/NVector/Nvector.h | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Sem. 08/NVector/Nvector.h (limited to 'Sem. 08') 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 + +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); -- cgit v1.3.1-23-gd82d