Answer the question
In order to leave comments, you need to log in
Is there an alternative to .Resize() for arrays?
In arrays, you need to declare the size, not like in Lists in c#, for example.
But often Lists are convenient for me, because the number of array elements changes in the process. And in C ++ there are no Lists at all, as far as I know. What to do then? How to correctly implement arrays so that they can be resized, and is there an alternative to .Resize(), because if the number of objects changes frequently, then each time recreating the array, I believe, is resource-intensive. What do you do if you need an array to which you periodically add or remove elements?
Answer the question
In order to leave comments, you need to log in
Dynamic array en.cppreference.com/w/cpp/container/vector
In general, they work on the principle "if we have an array of size n and we need to add n + 1 elements, we create a new array of size 2n, copy all the elements there and the new n + 1 th", so you can easily do it yourself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question