Check out example codes for "resizing dynamic array c++". It will help you in understanding the concepts better.

Code Example 1

void resize() {
    size_t newSize = size * 2;
    int* newArr = new int[newSize];

    memcpy( newArr, arr, size * sizeof(int) );

    size = newSize;
    delete [] arr;
    arr = newArr;
}

Learn ReactJs, React Native from akashmittal.com