When we allocate memory using new, where it is allocated in heap or stack?
Please tell me the difference between heap and stack?
new
allocates to the heap.
As a counter to Herb Sutter Free-store versus Heap:
http://zamanbakshifirst.blogspot.co.uk/2007/02/c-free-store-versus-heap.html
0xFFFF╔═════════════════╗
║ Stack Frames ║ Grows
╟─ ─ ─ ─ ─ ─ ─ ─ ─╢ │
╟─ ─ ─ ─ ─ ─ ─ ─ ─╢ │
╟─ ─ ─ ─ ─ ─ ─ ─ ─╢ ▼
╠═════════════════╣
║░░░░░░░░░░░░░░░░░║
║░Unalocated mem░░║
║░░░░░░░░░░░░░░░░░║
╠═════════════════╣ ▲
╟─ ░ ─ ─ ─ ─ ─ ░ ─╢ │
╟─ ─ The HEAP ─ ─╢ │
╟─ ─ ░ ─ ─ ░ ─░─ ─╢ Grows
╠═════════════════╣
║ Constant Data ║
╠═════════════════╣
║ Program Code ║
╠═════════════════╣
0x0000╚═════════════════╝ |
Last edited on by Canis lupus