Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I allocate / unallocate an array of things?

array unallocate
0
Posted

How do I allocate / unallocate an array of things?

0

Use new[] and delete[]: Thing* p = new Thing[100]; //… delete [] p; //older compilers require you to use “delete[100]p” Any time you allocate an array of things (ie: any time you use the “[…]” in the “new” expression) you *!*MUST*!* use the “[]” in the “delete” statement. The fact that there is no syntactic difference between a ptr to a thing and a ptr to an array of things is an artifact we inherited from C.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123