#include using namespace std; class DynamicArray { int *data; int nextIndex; int capacity; /// total size of the array public: DynamicArray(){ data = new int[5]; nextIndex = 0; capacity = 5; } DynamicArray(int c){ data = new int[c]; nextIndex = 0; capacity = c; } DynamicArray(DynamicArray const &d){ this->nextIndex = d.nextIndex; this->capacity = d.capacity; /// shallow copy this->data = d.data; /// deep copy this->data = new int[d.capacity]; for(int i=0;idata[i] = d.data[i]; } } void operator=(DynamicArray const &d){ this->nextIndex = d.nextIndex; this->capacity = d.capacity; /// shallow copy this->data = d.data; /// deep copy this->data = new int[d.capacity]; for(int i=0;idata[i] = d.data[i]; } } void add(int element){ if(nextIndex == capacity){ int *newData = new int[2*capacity]; for(int i=0;i=0 && i