When are variables removed from memory in C++?

前端 未结 11 1149
梦如初夏
梦如初夏 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:28

    Variable temp is stack allocated. That means it's deallocated when the function returns.

    See e.g.:

    • http://msdn.microsoft.com/en-us/library/ew5tede7%28VS.80%29.aspx
    • http://en.wikipedia.org/wiki/Stack_%28data_structure%29

提交回复
热议问题