okay, here's what I have.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
template <class T>
void Vector <T> :: resize (int capacity) throw (const char *)
{
try
{
data = new T[capacity];
}
catch
{
throw "ERROR: unable to allocate buffer";
}
for (int i = 0; i < numItems; i++)
T[i] = this->data[i];
delete [] this->data;
this->data = T;
this->capacity = capacity;
}
|
I'm getting these errors:
vector.h:258:8: error: structured binding declaration cannot have type ‘T’
T[i] = this->data[i];
^~~
vector.h:258:8: note: type must be cv-qualified ‘auto’ or reference to cv-qualified ‘auto’
vector.h:258:10: error: redeclaration of ‘auto i’
T[i] = this->data[i];
^
vector.h:257:13: note: ‘int i’ previously declared here
for (int i = 0; i < numItems; i++)
^
vector.h:260:18: error: expected primary-expression before ‘;’ token
this->data = T;
^
vector.h: In instantiation of ‘void Vector<T>::resize(int) [with T = double]’:
vector.h:231:7: required from ‘void Vector<T>::push_back(const T&) [with T = double]’
vector.h:218:7: required from ‘Vector<T>::Vector(int) [with T = double]’
assignment01.cpp:107:37: required from here
vector.h:258:8: error: redeclaration of ‘auto i’
T[i] = this->data[i];
^~~
vector.h:257:13: note: ‘int i’ previously declared here
for (int i = 0; i < numItems; i++)
^
vector.h:258:24: error: use of ‘i’ before deduction of ‘auto’
T[i] = this->data[i];