I have an array that holds a certain ClassType. I allocate memory with new for 10 positions of ClassType. At the end of the program I want to clean up the allocated memory so I delete all the ClassTypes in the array because I called them with new also. I want to do this but with a large class type.
Code: Select all
for(int i=0;i<length;i--)
{
delete arr+i;
}
delete [] arr;
Will this work ?
Code: Select all
for(int i=0;i<length;i--)
{
delete *arr[i];
}
delete [] arr;