How to insert dynamically into a std :: array?

7

I'm migrating from C language to C ++, and I want to stop using traditional C language media as the vector of it.

Is it possible to use std::array to insert elements dynamically as in std::vector ?

    
asked by anonymous 08.11.2016 / 15:52

1 answer

6

Congratulations, you're doing the right thing. C is C, C ++ is C ++.

Essentially it can not, this is a fixed size structure. The std:array is identical to the array of C, which does not allow you to insert new elements in it dynamically or statically. So if you want a replacement for the array , it's it, just do not demand from it what the C engine does not provide. If you want to dynamically manipulate it, it's very simple, use std:vector . Depending on the case you should even use a std::list .

Related: Difference between std :: list, std :: vector and std :: array

    
08.11.2016 / 15:59