Destructors

Started by
20 comments, last by Fruny 17 years, 7 months ago
It has nothing to do with the stack; statically-allocated objects such as globals are not stored on the stack.
Advertisement
Quote:Original post by Rainault
Is that because of the FIFO nature of the stack?


No. It's also true of variables that are statically allocated (i.e. globals) or variables that got constructed in the same scope. Destroying variables in reverse order is the simplest way to take care of any dependence issues. If B depends on A, B must be created after A and destroyed before it.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement