Glossary: Stack

OO codes are dynamic with objects being created and destroyed as required by the task in hand. Objects require memory to hold their data members. For objects created dynamically there are two sources:- Objects, and other variables, that are declared within any compound statement are created on the stack. When execution leaves the compound statement, the object's destructor is called and the stack memory space reclaimed. So stack-based objects are useful for short term work, but if an object has to exist beyond the end of statement, then they must be created on the heap using the new operator.
See OO Concepts:Constructors & Destructors
See First Steps Lesson: Stack & Heap Objects
Go Back to the The Glossary Top Page

If you have any comments about this page please send them to Nick West