Basically, both pieces of code allocate an array of pointers. For distribution, it does not matter why. Proper declaration is only necessary for type checking. Square braces should be read separately and means only an array.
Consider the following code as a quick example:
#include <stdio.h>
int main()
{
unsigned num = 10;
double **p1, ***p2;
p1 = new double*[num];
p2 = new double**[num];
printf("%d\n", sizeof(p1));
printf("%d\n", sizeof(p2));
delete [] p1;
delete [] p2;
return 0;
}
Yes, both are just pointers. And the allocated memory is sizeof (double *) * num.
source
share