a use p new tn and delete p fred p new


A: Use p = new T[n] and delete[] p:

 

Fred* p = new Fred[100];

...

delete[] p;

Any time you allocate an array of objects through new (generally with the [n] in the new expression), you have to use [] in the delete statement. This syntax is essential because there is no syntactic difference among a pointer to a thing and a pointer to an array of things (something we inherited from C).

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: a use p new tn and delete p fred p new
Reference No:- TGS0217526

Expected delivery within 24 Hours