I have an example:
int* arr = new int[1];
//First Time
arr[0] = 5;
cout << &arr[0] << " " << arr[0] << endl;
delete &arr[0];
cout << &arr[0] << " " << arr[0] << endl;
//Second time
arr[0] = 5;
cout << &arr[0] << " " << arr[0] << endl;
delete &arr[0]; //Error from here
cout << &arr[0] << " " << arr[0] << endl;
The result from the code above:
00529EF0 5
00529EF0 -572662307
00529EF0 5
//Where the code stop
I don't know why it causes me the error? It doesn't let me delete arr[0] the second time, even though the first time successfully deleted and I assign a new value for it.
deleteworked, doesn't mean it did. What are you trying to accomplish?deletesomething and then proceed as if that something is still valid. Basic recipe for things blowing up. I think it's on you to explain why you think this should work. (Forget the second deletion; why should something of the formdelete &X;followed byX = 5;ever work?)