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