-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vector.h
40 lines (29 loc) · 794 Bytes
/
Vector.h
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
#include <iostream>
double sqrt(double);
class Vector {
private:
double* elem;
int sz;
public:
Vector(std::initializer_list<double>);
Vector() {};
~Vector() { delete[] elem; }
Vector(const Vector& a); //copy constructor
Vector& operator=(const Vector& a); //copy assignment
Vector(Vector&& a); //move constructor
Vector& operator=(Vector&& a); //move assignment
friend Vector operator+(const Vector& a, const Vector& b);
void push_back(double);
explicit Vector(int s) :elem{new double[s]}, sz{s}
{
for(int i=0; i!=s; ++i)
elem[i] = 0;
}
double& operator[](int i);
const double& operator[](int i) const;
int size() const { return sz; }
};
/* Vector f(); */
/* void hello(); */
/* Vector init(int n); */
/* void bad_copy(Vector); */