the heap space

Oct 30, 2014 at 11:47pm
Hello i don't understand what the author of my e-book is saying about the heap below, can someone please try and explain it and how the "new double" works?


Heap memory is allocated using the new keyword followed by the type of
object to allocate. The new command breaks a chunk of memory off the heap
big enough to hold the specified type of object and returns its address. For
example, the following allocates a double variable off the heap:



1
2
3
4
5
double* child(void)
{
 double* pdLocalVariable = new double;
 return pdLocalVariable;
}
Last edited on Oct 31, 2014 at 12:14am
Oct 31, 2014 at 1:37am
Oct 31, 2014 at 3:20am
They are part of dynamic memory management.

how the "new double" works?

new double here means a new memory is allocated which has a type of double.

See for more info http://www.cplusplus.com/doc/tutorial/dynamic/
Topic archived. No new replies allowed.