احمد بندارى
احمد بندارى

Reputation: 43

How to delete this 2d dynamic array in c++

bool **arr=new bool* [row];
for(int i=0; i<9; i++)
{
    arr[i]= new bool[column];
}

I want to delete this dynamic array because it cause a problem with my RAM.

Upvotes: 1

Views: 2610

Answers (1)

πάντα ῥεῖ
πάντα ῥεῖ

Reputation: 1

You just delete in the reverse order it was allocated:

for(int i=0; i<9; i++) {
    delete [] arr[i];
}
delete[] arr;

Upvotes: 5

Related Questions