#pragma once template class Array { T* arr; unsigned size; unsigned allocated; void resize(); void free(); void copyFrom(const Array& other); public: Array(); ~Array(); Array(const Array& other); Array& operator=(const Array& other); Array(Array&& other); Array& operator=(Array&& other); }; template void Array::resize() { allocated *= 2; T* biggerArr = new T[allocated]; for (int i = 0; i < size; i++) { biggerArr[i] = arr[i]; } delete[] arr; arr = biggerArr; } template void Array::free() { delete[] arr; } template void Array::copyFrom(const Array& other) { this->size = other.size; this->allocated = other.allocated; this->arr = new T[allocated]; for (int i = 0; i < size; i++) { this->arr[i] = other.arr[i]; } } template Array::Array() { this->arr = nullptr; allocated = size = 0; } template Array::~Array() { free(); } template Array::Array(const Array& other) { copyFrom(other); } template Array& Array::operator=(const Array& other) { if (this != &other) { free(); copyFrom(other); } return *this; } template Array::Array(Array&& other) { this->arr = other.arr; other.arr = nullptr; } template Array& Array::operator=(Array&& other) { if (this != &other) { free(); this->arr = other.arr; other.arr = nullptr; } return *this; }