Cars::Cars( long id, int audienceRadius, const int numOfRow, const int numOfColumn) {
radius = audienceRadius;
row = numOfRow;
column = numOfColumn;
movieID = id;
arr1 = new int*[row];
for ( int i = 0; i < row; i++) {
arr1[i] = new int[column];
}
for (int j = 0; j < row; j++)
for (int k = 0; k < column; k++)
arr1[j][k] = 0;
}
Cars::~Cars() {
for(int i = 0; i < row; i++) {
delete [] arr1[i];
}
delete [] arr1;
}
2d dynamic array for parking area, and i am using this class on my other class where it stores those parking areas in class
AllParking::AllParking(){
//all park is also dynamic array
allparks = NULL;
numberOfParking= 0;
}
//can we delete like this?
AllParking::~AllParking(){
if(numberOfParking> 0)
delete[] allparks ;
}
My question is this cause any memory leak or error? When i am deleting allparks should i also delete member of arrays also or other destructor deletes that?