How to remove this 2D array in C ++

In a simple 1D array:

node *nodes =  new node[MAX_NODES];

Uninstall with:

delete [] nodes;

Deletes all nodes selected in the array.

But in this case:

float (*buildingArray)[3] = new float[10][3];

Is this operator the buildingArrayonly array of dimensions of 3 floating point pointers? And this is the line of liberation:

delete[] buildingArray;

Is the aforementioned release an deletearray, but I doubt if it will remove its links?

+5
source share
3 answers

Does the above selection highlight an array?

Yes Yes.

Just follow the rule:

You need to call deleteeither delete []as many times as you called newor new []accordingly.


, , .


std::vector std::array, .

+15

, . , , .

3 * 4, , 12 . , ( ), .

delete[] .

new delete , .

+3

new float[10][3] 10 3 floats ( 3 ).

delete[] .

, , , float, float[3].

+2

All Articles