mercredi 19 mai 2021

Initializing a 2D array with operator new

I am trying to declare a 2D array, where each element in the inner array has type uint64_t*. I want to do this in a single line using new, which should be possible in C++11 or later. I tried this:

uint64_t ***db = new uint64_t*[2][64];

However, this is incorrect:

cannot initialize a variable of type 'uint64_t ***' (aka 'unsigned long long ***') with an rvalue of type 'uint64_t *(*)[64]'

Note that the code works correctly when I replace the type with auto.

What is the correct type for the variable?

Aucun commentaire:

Enregistrer un commentaire