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
A: Name mangling is the rule according to which C++ modify function's name into function signature before passing that function to a linker. It is how the linker differentiates amo


write an algorithm for multiplication of two sparse matrices using linked lists

Write a program of constructors and destructors Make a class drugs having encapsulated data for medicine name, whether solid or liquid, price and purpose of use. From this clas

Mixed Mode Expressions and Implicit type Conversions A mixed mode expression is one in which the operands are not of the similar type. In this case, the operands are converted

Specifying a Class: As discussed a class is defined to develop an algorithm and bind it together in a core shell. A class is an abstract data type (ADT).  The binding of dat

Requirements: 1.  This assignment as well as other assignments in this class must be finished on Windows operating system. 2.  Zip your program and submit the zip file on ANG

Virtual Base Classes This ambiguity can be resolved if the class derived have only one copy of the class base. This can be done by making the base class a virtual class. This k

The Shortest Job Next (SJN) algorithm queues processes in a way that the ones that use the shortest CPU cycle will be selected for running rst. Shortest remaining time rst algori

In this assignment, you will develop a program named "match" to be used by a dating service to form couples. Given the number of gentlemen, the number of ladies, and a list of acce