Describe how can i allocate/unallocate an array of things?, C/C++ Programming

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).

 

Posted Date: 3/19/2013 8:42:24 AM | Location : United States







Related Discussions:- Describe how can i allocate/unallocate an array of things?, Assignment Help, Ask Question on Describe how can i allocate/unallocate an array of things?, Get Answer, Expert's Help, Describe how can i allocate/unallocate an array of things? Discussions

Write discussion on Describe how can i allocate/unallocate an array of things?
Your posts are moderated
Related Questions
WAP TO PRINT THE LARGEST NUMBER FROM ANY 10 NUMBERS #include stdio.h> #include conio.h>   void main()   {                    int a[10],i,max;

what is the purpose of pointer ? what is the syntax? how it works?

Many modern cryptography algorithms require two numbers that are coprime, or sometimes referred to as relatively prime. Two numbers are coprime if their greatest common divisor is

electricity biil code

write a c program to solve exanple of lamis therom

For the circuit shown in Figure, verify the p.d. across resistor R3. If the total resistance of the circuit is 100Ω, verify the current flowing by resistor R1. Find also the

Requirements Create a "makefile" that will manage the construction of a program The name of the makefile must be: makefile The make file must produce an executable

There are formal ways of reducing Boolean expressions in order to minimize the logic circuit. The two elementary ways of minimization are using Boolean expressions/De Morgan Theore


Why should I employ new instead of truthful old malloc()? A: Constructors/destructors, type safety, overridability. Constructors/destructors: unlike malloc(sizeof(Fred)), new