The following error occurs during compilation and running.
Access violation reading location 0xccccccc0
One-step debugging: an error occurs when a pointer variable is deleted. The error is caused by the deletion of a pointer variable without a new one.
Therefore, you must carefully check the object creation status before the delete operation.
To sum up the error-prone parts of delete:
Int * A = new int [10];
......
Delete [];
----------------------------------------------------------
When Delete [] A; is followed by an error:
1. You intentionally or unintentionally changed the first address of array A, such as a ++;
2. Scope of the variable. For example, if you are new in a function body but delete in another function body, the variable is no longer valid, in this case, the error message "a" is an unknown identifier in the delete statement;
3. the operation has been deleted once. You cannot delete the operation twice;
4. Memory Access out of bounds. VC allocates memory. In addition to allocating the memory space you need, some management units are allocated, which is at the upper and lower bounds of your allocated space, for example, the memory boundary flag (0 xfdfdfdfd) records the number of array elements in the upper bound of the array. If you modify the management information, an error will be reported during the delete operation.