dymamic - Copying dynamic array in C++ -
if have like:
int **arr=new int *[3]; and want make this array double size, need make new array:
int **temp=new int *[6] and copy arr temp, , copy temp arr.
how this?
you're on right track. need is:
allocate array of size 6 (you did that).
copy 3 elements of pointed
arr6-array.deallocate memory pointed
arr.point
arr6-array.
for 2, use for loop. 3, use delete[]. 4, use pointer assignment.
i'm giving hints instead of code, it's still work in end. purpose of homework learning, after all.
Comments
Post a Comment