#include
using namespace std;template<class T>
class MyArray {friend void test01();
public:MyArray(int capacity){this->mCapacity &#61; capacity;this->mSize &#61; 0;this->ptr &#61; new T[this->mCapacity];}MyArray(const MyArray<T>& another){this->mCapacity &#61; another.mCapacity;this->mSize &#61; another.mSize;this->ptr &#61; new T[this->mCapacity];for (int i &#61; 0; i < this->mSize; i&#43;&#43;){this->ptr[i] &#61; another.ptr[i];}}T& operator[](int index){return this->ptr[index];}MyArray<T>& operator&#61;(const MyArray<T>& another){if (this->ptr !&#61; nullptr) {delete[] this->ptr;this->ptr &#61; nullptr;this->mCapacity &#61; 0;this->mSize &#61; 0;}this->mCapacity &#61; another.mCapacity;this->mSize &#61; another.mSize;this->ptr &#61; new T[this->mCapacity];for (int i &#61; 0; i < this->mSize; i&#43;&#43;){this->ptr[i] &#61; another.ptr[i];}return *this;}void PushBack(T& data) {if (this->mCapacity <&#61; this->mSize) {return ;}this->ptr[this->mSize] &#61; data;this->mSize&#43;&#43;;}void PushBack(T&& data) {if (this->mCapacity <&#61; this->mSize) {return ;}this->ptr[this->mSize] &#61; data;this->mSize&#43;&#43;;
}~MyArray() {if (this->ptr !&#61; nullptr) {delete[] this->ptr;this->ptr &#61; nullptr;this->mCapacity &#61; 0;this->mSize &#61; 0;}}
private:int mCapacity;int mSize;T* ptr;
};
void test01() {MyArray<int> marray(20);int a &#61; 10, b &#61; 20, c &#61; 30;marray.PushBack(a);marray.PushBack(b);marray.PushBack(c);marray.PushBack(1);marray.PushBack(2);marray.PushBack(3);for (int i &#61; 0; i < marray.mSize; i&#43;&#43;) {cout << marray[i] << " ";}
}int main() {test01();
}