I am wondering how can i use the delete operator if I want to delete an array initialized like this:
int (*my_ptr)[10] = new int[3][10];
This seems invalid:
delete[][]
new int[3][10] is simply creation of a dynamic array whose elements are themselves arrays. This is deleted in the same way as all dynamic arrays: delete[].
my_ptr is an array of 3 elements. Each element is an int[10] type.
You call delete[] my_ptr; to delete those 3 elements.
delete[][]is invalid. Usedelete[]. It will should call all destructors , as required.