the heap space

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