PRODUCT : Borland C++ NUMBER : 1732 VERSION : All OS : All DATE : October 25, 1993 PAGE : 1/2 TITLE : Declaring a multi-dimensional array pointer /* NEWARAY.CPP - The declaration of a multi-dimensional array pointer "The operator new with arrays: If 'name' is an array, the pointer returned by 'new' points to the first element of the array. When creating multidimensional arrays with 'new', all array sizes must be supplied: mat_ptr = new int[3][10][[12]; // OK mat_ptr = new int[3[][12]; // illegal mat_ptr = new int[][10][12]; // illegal" pg 111, BC++ 2.0.d1 Programmer's Guide pg 109, BC++ 3.0.d1 Programmer's Guide pg 109, BC++ 3.1.d1 Programmer's Guide QUESTION: How is 'mat_ptr' declared? */ #include const dim1 = 10; const dim2 = 10; const dim3 = 10; // Global data is allocated from the default data segment int int_ptr1[dim1][dim2][dim3]; //************************************************************* void main(void) { // local (automatic) data is allocated from the stack int int_ptr2[dim1][dim2][dim3]; // Static data is allocated from the default data segment static int_ptr3[dim1][dim2][dim3]; cout << endl << sizeof(int_ptr3); // First dimesnion is not specified... int (*int_ptr4)[dim2][dim3]; // ...until we do the actual allocation. Dynamic allocations // are taken from the heap. PRODUCT : Borland C++ NUMBER : 1732 VERSION : All OS : All DATE : October 25, 1993 PAGE : 2/2 TITLE : Declaring a multi-dimensional array pointer int_ptr4 = new int [dim1][dim2][dim3]; if (!int_ptr4) cout << "\nError allocating array 'int_ptr4'"; int i, j, k; for (i=0; i