With this statement
int** items[5];
in reality, you are declaring an array of 5 elements which are pointers to pointers. I honestly don’t understand why you need something this complicated.
What I think you need is simply an array of pointers
int* items[5]; // array de 5 ponteiros
or the pointer to other pointers.
int** items;
Think about what you’re doing with this instruction:
*items[i] = new int;
What is items[i]
?
Pointer.
What happens if you un-reference a pointer?
You access the pointed memory, but in your case there is no allocated memory. To allocate memory to the second level pointer you have to first allocate memory to those of first.
What you have to do first is to allocate memory for the array pointers and only then for the pointers that the pointers of the pontoon array.
int** array[2];
array[0] = new int*; // alocar memoria para um ponteiro que ponta a um ponteiro
*array[0] = new int; // agora podes alocar memoria para o ponteiro de segundo nivel.
take an asterisk from the item declaration. what Voce is doing and allocating a 5-position vector with pointers to other vectors. then a 3-dimensional matrix.
– Lucas Virgili
What error does the debugger indicate?
– Oralista de Sistemas