
1 MyArray.hpp
//自己的 同用的数据类
#pragma once
# include <iostream>
template<class T>
class MyArray
{
public:
MyArray(int capacity)
{
//cout << "MyArray有参函数调用" << endl;
this->m_Capacity = capacity;
this->m_Size = 0;
this->pAddress = new T[this->m_Capacity];
}
//拷贝构造函数
MyArray(const MyArray& arr)
{
//cout << "MyArray拷贝函数调用" << endl;
this->m_Capacity = arr.m_Capacity;
this->m_Size = arr.m_Size;
this->pAddress = new T[this->m_Capacity];
for (int i = 0; i < this->m_Size; i++)
{
this->pAddress[i] = arr.pAddress[i];
}
}
//operator = 防止浅拷贝问