This is not for anything in particular, just for curiosity. If I had to allocate memory in a vector of pointers, how would i delete that allocated memory?
For demonstration purposes, i wrote a program that fills a vector of pointers to type int, and then I allocated memory arrays and filled them with zeros. I then printed the results.
and to be extra clear:
delete it multiple times
is the problem. you can only delete memory you own (from a new statement). You can only do this once -- a lot of programmers set the pointer to null so deleting it a second time is harmless. (when you have one copy, nulling it works).
Copying pointers (which you did here, each vector entry is a copy of the same pointer) leads to confusion around deletes; if you deleted one, you deleted them all, and confusion around the data as well: if you modified the contents (memory pointed to) in one, you modified them all. Pointers require precise coding or you can get into trouble fast.
as a side note: if you wrapped the raw pointer in a class with a delete destructor, it would self clean when vector went out of scope. And there are advanced pointer types as well, but you said it was just playing around code...
also, if you create with new[] (array), then destroy with delete[] (note the brackets)
if you create with new (element) then destroy with delete (note the lack of brackets)
so in your code it should be delete[] a_vector[7]; (¿do you understand why I wrote 7 there?)