When a function ends are its local variables deallocated?

前端 未结 4 1299
日久生厌
日久生厌 2021-01-02 05:20

If not does that mean that I would have to end each function by deleting all local variables if I wanted to prevent 100% of memory leak?

4条回答
  •  迷失自我
    2021-01-02 05:30

    Dynamically allocated memory using malloc, realloc, new, and new[] must be deleted. These are in heap memory. Others would get automatically deallocated.

提交回复
热议问题