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
Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

What are the various types of control structures in programming? - Primarily there are 3 types of control structures in programming: Sequence, Selection and Repetition. - Se

1. De ne a function chomp :: String -> String that selects a run of repeated characters from the start of a string with the run being as long as possible. For example ch

Project Description: I want an experienced programmer to program an RFID tag that will be read (maybe also written), and perform a call to a Filmmaker Pro 13 database. Skills

Explain the working of Array with Strings? A string is defined in C language as an array of characters. A null character (‘\0') is automatically added to the end of the charact


SquareMaze The SquareMaze class should be declared and defined in maze.h and maze.cpp, respectively. Each SquareMaze object will represent a randomly-generated square maze and its

how to create program in c that will system restart

Rule: To determine the canonical form we should OR the min terms. A min term is defined as a Boolean equation of the input if the output is logic '1'. If the input is logic '1'

Operators The variables, which are declared and explained, are the operands, which are operated upon by the operators. Operators specify what operations are to be performed on