-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuple.cpp
More file actions
24 lines (19 loc) · 549 Bytes
/
Copy pathTuple.cpp
File metadata and controls
24 lines (19 loc) · 549 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "Tuple.h"
#include <stdexcept>
Tuple::Tuple(const int *values, unsigned int numValues) {
// Copy from values into a new array
this->values = new int[numValues];
for (unsigned int i = 0; i < numValues; ++i) {
this->values[i] = values[i];
}
this->numValues = numValues;
}
Tuple::~Tuple() {
delete[] this->values;
}
int Tuple::getValue(unsigned int index) const {
if (index >= this->numValues) {
throw std::invalid_argument("Tuple index out of bounds");
}
return this->values[index];
}