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:

  1. allocate array of size 6 (you did that).

  2. copy 3 elements of pointed arr 6-array.

  3. deallocate memory pointed arr.

  4. point arr 6-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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -