Storage binding and deallocation

I'm doing a study guide for my programming class and here is one of the questions. I don't really know how to answer it.

Storage bindings. In C++ how do you create the following types of storage:

a. static storage that holds one int
b. stack-dynamic storage that holds one int
c. explicit heap-dynamic storage that holds one int


How are following kinds of storage in C++ deallocated?

d. stack-dynamic storage
e. explicit heap-dynamic storage
"storage" refers to using memory.

a. How do you create a variable that is statically allocated (not found in a function*)?
b. How do you create a variable that is only created and used for a certain amount of time (found in a function*)
c. How do you create a variable on the heap?

d. How do variables of type (a) and (b) disappear*?
e. How do variables of type (e) disappear*?

*caveats - there are ways to put static variables in functions (using the static keyword), you can create "stack-dynamic" variables using { and } in loops etc, and terminating a program will almost always make all variables disappear, but what is the way to do it without terminating your program, if possible?

Hope this helps.
Topic archived. No new replies allowed.