#ifndef ARRAYT #define ARRAYT #include template class ArrayT { public: ArrayT(){}; ArrayT(size_t c); ArrayT(const ArrayT & src); ~ArrayT(); ArrayT & operator = (const ArrayT & src); void PushBack(T); void PopBack(); T & operator[] (size_t index); size_t Size() const; size_t Capacity() const; private: size_t size{0}, capacity{0}; T * data{nullptr}; }; template ArrayT::ArrayT(size_t c){ capacity = c; data = new T[capacity]; } template ArrayT::ArrayT(const ArrayT & src){ size = src.size; capacity = src.capacity; data = new T[capacity]; for(size_t idx = 0; idx < size; ++idx) { data[idx] = src.data[idx]; } } template ArrayT::~ArrayT() { delete [] data; } template ArrayT & ArrayT::operator = (const ArrayT & src) { if (this != &src) { size = src.size; capacity = src.capacity; if (data != nullptr) { delete [] data; } data = new T[capacity]; for(size_t i = 0; i < size; ++i) { data[i] = src.data[i]; } } return * this; } template void ArrayT::PushBack(T i){ T * tmp{nullptr}; if (size == capacity) { ++capacity ; tmp = new T[capacity]; for(size_t idx = 0; idx < size; ++idx) { tmp[idx] = data[idx]; } delete [] data; data = tmp; tmp = nullptr; } data[size] = i; ++size; } template void ArrayT::PopBack(){ if (size >0) { --size; } } template T & ArrayT::operator[] (size_t index){ if (index size_t ArrayT::Size() const{ return size; } template size_t ArrayT::Capacity() const{ return capacity; } #endif