In C++, what happens when the delete operator is called?
In C++, I understand that the `delete` operator, when used with an array, 'destroys' it, freeing the memory it used. But what happens when this is done?

I figured my program would just mark off the relevant part of the heap being freed for re-usage, and continue on. 

But I noticed that also, the first element of the array is set to null, while the other elements are left unchanged. What purpose does this serve?

	int * nums = new int[3];
	nums[0] = 1;
	nums[1] = 2;
	
	cout << "nums[0]: " << *nums << endl;
	cout << "nums[1]: " << *(nums+1) << endl;

	delete [] nums;

	cout << "nums[0]: " << *nums << endl;
	cout << "nums[1]: " << *(nums+1) << endl;
In C++, what happens when the delete operator is called?
===

In C++, I understand that the `delete` operator, when used with an array, 'destroys' it, freeing the memory it used. But what happens when this is done?

I figured my program would just mark off the relevant part of the heap being freed for re-usage, and continue on. 

But I noticed that also, the first element of the array is set to null, while the other elements are left unchanged. What purpose does this serve?

	int * nums = new int[3];
	nums[0] = 1;
	nums[1] = 2;
	
	cout << "nums[0]: " << *nums << endl;
	cout << "nums[1]: " << *(nums+1) << endl;

	delete [] nums;

	cout << "nums[0]: " << *nums << endl;
	cout << "nums[1]: " << *(nums+1) << endl;