How to create a dynamic array of 100 elements? How to delete then the value of each element? How to remove the entire dynamic array?

    2 answers 2

    If you did not create each element separately, then you need to delete everything together. In the case of arrays, this is delete[] имя_массива; - pair function to new[]

      In my opinion, in C ++ the right way is to use std::vector .

      Creating an array is simple:

       std::vector v(100); 

      It is not necessary to delete it: vector will self-delete when it leaves the surrounding block of visibility. To control the lifetime of the array, either get it in the right block, or put it in some class, or put it in dynamic memory - there are many options, described in the book on C ++, which I hope you are reading now.