I made a dynamic array (example):
int *a;
a = new int[3];
a[0] = 10; a[1] = 20; a[2] = 30;
Than I create a vector which stores pointers:
vector<int*> pa;
pa.push_back(&a[0]);
After I deleted (freed) the memory with "delete[] a;", I can still access to the element, that I push_backed. (cout << *pa[0]; output: 10)
Why is this happen? When I "delete[] a", it only deletes the pointer to the elements, but the elements are still accessable?