How to dynamically allocate arrays in C++
for arrays (which is what you want) or for single elements. But it’s more simple to use vector, or use smartpointers, then you don’t have to worry about memory management. L.data() gives you access to the int[] array buffer and you can L.resize() the vector later. L.get() gives you a pointer to the int[] array.