Array using Class | SoloLearn: Learn to code for FREE!


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?

5/23/2020 7:01:15 AM

Aniket Roy

2 Answers

New Answer


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);


You do know that C++11 introduced the array class don't you?