Contents Up << >>

How do I allocate/unallocate an array of things?

Use new[] and delete[]:

  	Fred* p = new Fred[100];
	//...
	delete [] p;
Any time you use the brackets "[]" in the new expression, you must use "[]" in the delete statement. This syntax is necessary because there is no syntactic difference between a pointer to a thing and a pointer to an array of things (something we inherited from C).