Automatic memory is used on normal variables.
The following two lines are equivalent with the current standard:
1 2
int x;
autoint x;
1 2 3 4 5 6 7 8 9 10 11
int *Dynamic;
{
staticint Static; // allocated only once - at runtime -
int Auto; // allocated each time the current { } block is executed
Dynamic = newint; // allocated when you want - each call of new -
} // Auto is destructed when out of scope
delete Dynamic; // Dynamic deleted whenever you want
// Static is destructed when the program ends
* Stack-based memory allocation allocates space for auto variables,
* Heap-based memory allocation allocates space for dynamic variables (created by 'new' operator),
* Static memory allocation allocates space for global and static variables.