Thursday, July 30, 2009

How do you delete an array in C++?

Use "delete [] someArrayPtr":





double *data = new double[20];


delete [] data;


data = NULL;





('Course, this only applies if you created your array on the heap with "new". Assigning the pointer to be NULL afterwards is good style, since it otherwise would point to now-invalid memory.)

How do you delete an array in C++?
double * xd;





xd = (double *)VirtualAlloc(NULL, useMem, MEM_COMMIT, PAGE_READWRITE);


if (xd == NULL)


{


return FALSE;


}





VirtualFree(xd, 0, MEM_RELEASE);


No comments:

Post a Comment