Array Flashcards
Array();
template <class T>
Array<T>::Array(){
elements = new T[MAX_ARR];
numElements = 0;
}
~Array();
template <class T>
Array<T>::~Array(){
delete [] elements;
}
Array<T>& operator+=(const T&);
template <class>
Array<T>& Array<T>::operator+=(const T& t){
if (numElements < MAX_ARR){
elements[numElements++] = t;
}
return *this;
}</T></T></class>
Array<T>& operator-=(const T&);
template <class T>
Array<T>& Array<T>::operator-=(const T& t){
for(int i = 0; i < numElements; i++) {
if(elements[i] == t) {
for(int j = i; j < numElements - 1; j++) {
elements[j] = elements[j + 1];
}
numElements–;
break;
}
}
return *this;
}
T& operator[](int index);