I want to get something clear that I found most sources so confusing.
For example,
int *a=new int;
Is "a" in stack or heap, and what about "*a"? Most sources I found only refer to heap, I really need an extremely concrete answer. I would be really grateful.
a is in the stack. When the scope of a ends, a is not usable.
*a is in the heap. Even after the scope of a ends, the object that a points to continues to live unless the memory is deallocated before that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With