[Solved] Delete a pointer with a pointer to that pointer


You just need to delete the array referenced by del:

delete[] del;

You are already deleting the arrays referenced by hello and bye:

delete[] * del; 
delete[] * (del + 1);

Though this would be more idiomatic:

delete[] del[0];
delete[] del[1];

Or even better, avoid using new and delete altogether, taking advantage of modern C++ features. What you are writing looks more like C.

#include <array>
#include <numeric>
#include <tuple>

template<typename T, std::size_t N>
std::array<T, N> make_increasing_array(T initial = T())
{
  std::array<T, N> array;
  std::iota(array.begin(), array.end(), initial);
  return array;
}

int main()
{
  auto del = std::make_tuple(
    make_increasing_array<unsigned int, 6>(),
    make_increasing_array<unsigned int, 4>());

  auto& hello = std::get<0>(del);
  auto& bye = std::get<1>(del);
}

6

solved Delete a pointer with a pointer to that pointer