Object objects[theCapacity]; iterator insert(int pos,const Object& x) { Object* oldArray=objects; theSize++; int i=0; if(theCapacity<theSize) theCapacity=theSize; objects=new Object[theCapacity]; while(i!=pos) { objects[i]= oldArray[i]; i++; } objects[pos]=x; for(int k=pos;k<theSize;k++) objects[k+1]=oldArray[k]; delete[] oldArray; return &objects[pos]; }
时间: 2024-10-11 13:36:03