Can I use blocks to manage memory consumtion in C++?

后端 未结 4 1037
萌比男神i
萌比男神i 2020-12-11 07:10

I\'m trying to gain some memory saving in a C++ program and I want to know if I can use blocks as a scope for variables (as in Perl). Let\'s say I have a huge

4条回答
  •  我在风中等你
    2020-12-11 07:27

    Yes, you can.

    The destructor will be called as soon as the variable falls out of scope and it should release the heap-allocated memory.

提交回复
热议问题