I want to ask some of the problems about C++ memory leak. And what is my mistake of my programme and how to rewrite the programme to prevent memory leak. Thank you
int **ptr = new int*[5];
for (int i = 0; i < 5; i++)
ptr[i] = new int (i+1);
delete ptr;
newandnew[]statements and the number ofdeleteanddelete[]statements and see whether they match. You have 1new[]and 5news. You have 0delete[]s and 1delete. So in this case none of thenew[]ornewallocations you created are being cleaned up correctly.