What happens to memory of variable after loops? (C++) -


i'm trying understand how c++ works. when u declare new variable (int x) within loop, example within for-loop. memory allocated variable x within loop, happens memory after exiting for-loop? understanding friend java automatically de-allocate memory, c++?

thanks.

it deallocated if declared on stack (i.e. via int x = ...) , when variable leaves scope. won't deallocated if declared on heap (i.e. via int *x = new int(...)). in case have explicitely use delete operator.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -