You should probably check this->grid[i][j] != nullptr before deleting it.