#include "iostream"
using namespace std;
template<class T>
class arry
{
private:
T *p;
unsigned int size;
public:
arry(){}
arry(unsigned int _size):size(_size){
p=(T*)malloc(_size*sizeof(T));
}
void resize(){
size+=1;
p=(T*)realloc(p,size*sizeof(T));
}
T& operator[](int n){
return *(p+n);
}
};
int main()
{
arry<int> A(3);
A[0]=1;
cout<<A[0]<<endl;
return 0;
}
c++简单的动态数组实现
最新推荐文章于 2025-02-16 11:18:07 发布