RAD Studio |  |

The Operator new With Arrays
See Also
Collapse All

When using the array form of operator new[](), the pointer returned points to the first element of the array. When creating multidimensional arrays with new, all array sizes must be supplied (although the leftmost dimension doesn't have to be a compile-time constant):

Copy Code

    mat_ptr = new int[3][10][12];    // OK
    mat_ptr = new int[n][10][12];    // OK
    mat_ptr = new int[3][][12];      // illegal
    mat_ptr = new int[][10][12];     // illegal

Although the first array dimension can be a variable, all following dimensions must be constants.

See Also

The keyword new

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!