Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 08 / NVector / Nvector.h
blob: 6c63124f4fca5fd3daf8565ae8e9c5ca7c5477ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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);