-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyVector.cpp
More file actions
63 lines (51 loc) · 1.5 KB
/
MyVector.cpp
File metadata and controls
63 lines (51 loc) · 1.5 KB
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
54
55
56
57
58
59
60
61
62
63
#include "MyVector.h"
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;
// Initialize static member
int MyVector::DEFAULT_CAPACITY = 3;
// Default constructor
MyVector::MyVector() {
// TODO(student): implement this and remove this comment
}
// Copy constructor
MyVector::MyVector(const MyVector &other) {
// TODO(student): implement this and remove this comment
}
// Assignment operator
MyVector &MyVector::operator=(const MyVector &other) {
// TODO(student): implement this and remove this comment
return *this;
}
// Returns the current capacity
int MyVector::capacity() const {
// TODO(student): implement this and remove this comment
return 0;
}
// Returns the number of elements
int MyVector::size() const {
// TODO(student): implement this and remove this comment
return 0;
}
// Adds an element to the end
void MyVector::push_back(int x) {
// TODO(student): implement this and remove this comment
}
// Removes the last element. Assumes size > 0.
void MyVector::pop_back() {
// TODO(student): implement this and remove this comment
}
// Access specified element
int &MyVector::operator[](int index) {
// TODO(student): implement this and remove this comment
return DEFAULT_CAPACITY; // placeholder to avoid compiler warning
}
// Destructor
MyVector::~MyVector() {
// TODO(student): implement this and remove this comment
}
// Doubles the capacity of the underlying array
void MyVector::doubleCapacity() {
// TODO(student): implement this and remove this comment
}