-
Notifications
You must be signed in to change notification settings - Fork 0
/
myVector.hpp
53 lines (39 loc) · 956 Bytes
/
myVector.hpp
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
53
/**
* Definition of base Vector class, from which RowVector, ColumnVector and Matrix classes are derived.
*/
#ifndef MYVECTOR_H
#define MYVECTOR_H
#ifndef EXCEPTIONS_H
#include "exceptions.hpp"
#endif
#include <stddef.h>
#include <iostream>
/**
* Definition of base Vector class. Note: this is an abstract class!
*/
template <typename T>
class myVector
{
public:
myVector();
myVector(const size_t len);
void push_back(const T val);
void pop_back();
T& operator[](const size_t idx) const;
void setValue(const size_t idx, const T val);
T* begin() const;
T* end() const;
T& back() const;
size_t size() const;
size_t capacity() const;
bool empty() const;
virtual void print() const = 0;
void clear();
~myVector();
protected:
T* myBuffer = nullptr;
size_t mySize = 0;
size_t myCapacity = 0;
void reserve(size_t newCapacity);
};
#endif