When are variables removed from memory in C++?

前端 未结 11 1148
梦如初夏
梦如初夏 2020-12-16 06:54

I\'ve been using C++ for a bit now. I\'m just never sure how the memory management works, so here it goes:

I\'m first of all unsure how memory is unallocated in a fu

11条回答
  •  情歌与酒
    2020-12-16 07:13

    Its not removed from memory once the function exits.

    It remains in memory, in addTwo's stack frame, until some other process (or the same) re uses that portion of memory.

    Until that point, accessing temp is undefined behaviour.

提交回复
热议问题