salute..
I am learning dynamic allocations for multidimensional arrays in a book and I found some ways for that, And now haven’t problem in it.
But the author of the book shows us a way, but it doesn’t work correctly. It is this:
pbeans = new double [3][4]; // Allocate memory for a 3x4 array
And this is the error:
error C2440: '=' : cannot convert from 'int (*)[4]' to 'int *'
how should i define pbeans ( if this type of coding is legal)?
and what is the problem exactly?
Regards.
This is covered in my FAQ on arrays:
For the “C declarator impaired”, you could make that more readable with a typedef:
But in C++, we prefer RAII containers over raw pointers:
Note the complete absence of
delete[]which makes this solution exception-safe.