Memory | SoloLearn: Learn to code for FREE!

0

Memory

can anyone explain what is the difference between stack and heap please.

c++

12/9/2016 1:30:03 PM

Mohammed Mshragi

2 Answers

New Answer

+1

Stack is when memory is allocated at compile time which definitely means that you know the amount of memory to be assigned to a value or anything when the program starts running. Heap is when memory is allocated dynamically at runtime. It means that you dont know the amount of memory that will be used when the program starts running.

0

stack *last in first out data structure *used for pass by value type storage *keeps the original copy of data *static in nature, doesn't permits change heap *it's a tree like data structure *used for pass by reference type data *keeps a reference for the actual data *implemented using pointer and address variables *dynamic in nature