newed variable after deletion?
|Now, when my program exits, will anything( The OS etc ) take care of any allocated memory and release it back to the OS?|
The issue is not whether the OS releases the memory or not. All modern protected OSes will release the memory occupied by the program when the program terminates.
The issue is that it's a poor programming practice not to do so. If you get in the habit of being careless about releasing memory in your program, when you tackle more complex programs where there are lots of objects with different lifespans, you will have memory leaks that will be hard to find and difficult to fix.
Consider a threaded program, or a windowed or event driven program where objects are created upon an event. You want to be very sure that the objects (and memory owned by them) are released and do not create memory leaks or your program may crash due to heap exhaustion.
|but I can still output the size of a newed variable after deletion?|
new, but when I do, it's in a class, then the dtor takes care of the rest.