The Vec setSize(newSize) method should follow these steps:
- If mySize and newSize are different:
- If newSize is zero:
- Deallocate myArray;
- Set myArray to nullptr;
- Set mySize to zero.
- Otherwise:
- Allocate a new dynamic array of Items,
storing its address in local variable newArray.
- If mySize is less than newSize:
- Copy mySize values from myArray into newArray.
- Set the remaining (newSize-mySize) values to zero.
Otherwise, just copy newSize values from myArray into newArray.
- Set mySize to newSize.
- Deallocate myArray.
- Set myArray to newArray.