The definitions the SetBase and SetLength member functions of the Array<T> class are given in Program . The SetBase function simply modifies the base field as required. The SetLength function provides a means to change the size of an array at run time. This function can be used both to increase and to decrease the size of an array.
Program: Array<T> Class SetBase and SetLength Member Function Definitions
The running time of this algorithm depends on two parameters. If n is the original size of the array and m is the new size of the array, then the running time of Resize is . This is because the program first allocates and initializes a new array of size m; then it copies at most elements from the old array to the new array; and then it deletes the old array. And in the case where T is a built-in C++ data type, this simplifies to .