0

Array using Class

I tried creating an array and performed basic operation using class and an object (pointer object actually). Everything went well and good. But when I tried creating another pointer object to copy the elements of the first array into the second new array using a function named Array* Another(), it is not working. I have doubt in that function "Array* Another()". What is wrong? https://code.sololearn.com/c9tlFKq10iDd/?ref=app

23rd May 2020, 7:01 AM
Aniket Roy
Aniket Roy - avatar
2 Respostas
+ 1
The second array you are making doesn't have a size or an array it can write into. It's empty! You should probably make a function like `setsize` but where you can give a size as an argument. Then you can arr2 = new Array(); arr2->resize(length); Or you can even do it in a constructor if you know about those. arr2 = new Array(length);
23rd May 2020, 7:10 AM
Schindlabua
Schindlabua - avatar