Consider a Dynamic Array declared inside the code using int* z = new int[10]; . How we will free the memory after we are done with the z array?
#include <iostream>
using namespace std;
int main()
{
int* z = new int[10];// use of the 'new' operator is allocating memory for arrays.
// some array operations
z[5]=10;
cerr<< z[5];
// operator delete [] to free the allocated memory array
delete[] z;
return 0;
}
Comments