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
Post a Comment