0
Why do we need to store data in The Heap ?
We know that in C++ there are to places to store data - 1. The Stack and 2. The Heap . So why do we store and use the data in heap while we can just use the stack ? I know it maybe explained in the course but I am having problem to understand this . Please Help .
4 Respuestas
+ 1
What would you do when you don't know the maximum amount of memory your program would be allocating ?
0
Arsenic Ya I know that sometimes the data need is not known . But the stack doesnt has any limits for data ?
0
Scope is also one consideration, heap based memory lifetime is not limited as is the stack based memory. Memory allocated on the heap stays until explicitly destroyed, with the exception of smart pointers, *probably* ...
https://stackoverflow.com/questions/40701228/why-do-we-use-heap-to-store-memory
0
Not only two memory area stack, heap are available read about assembly you will understood better about memory concepts and working process.