I need to have a dynamic array, so I need to allocate the required amount of memory through a pointer. What makes me think about what is a good solution is that C ++ has the ability to do something like:
int * p = new int[6];
which allocates the required array. I need, then, I want to grow some parts of this array. Example (n erroneous):
int *p1 = &p[0];
int *p2 = &p[2];
int *p3 = &p[4];
delete [] p2;
p2 = new int[4];
I do not know how to achieve this behavior.
EDIT: std::vectordoes not work for me, since I need the time to insert / delete items in kproportion to the number k, not the number of items stored in std::vector.
, , , . , ( "", "" ).