Stack vs. Heap

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Google is your friend.

From here :

Stack allocation is a work of compiler. All stack variables are automatic. When variable is out of scope, compilere deletes stack objects automatically. The stack is memory area that temporarily holds the arguments to the function as well as any variables that are defined local to the function.

The heap is a separate area from the program and the stack.You use new ( malloc in C) and delete(free in C) to allocate and deallocate objects in heap memory. The advantage if using new and delete is they provide an efficient wat to allocate and deallocate memory.