Automatic tells me something about the lifetime of an object: specifically that it is bound automatically to the enclosing scope, and will be destroyed automatically when that scope exits.
Dynamic tells me that the lifetime of an object is not controlled automatically by the compiler, but is under my direct control.
Stack is an overloaded name for a type of container, and for the related popular instruction pointer protocol supported by common call
and ret
instructions. It doesn't tell me anything about the lifetime of an object, except through a historical association to object lifetimes in C, due to popular stack frame conventions.
Note also that in some implementations, thread-local storage is on the stack of a thread, but is not limited to the scope of any single function.
Heap is again an overloaded name, indicating either a type of sorted container or a free-store management system. This is not the only free store available on all systems, and nor does it tell me anything concrete about the lifetime of an object allocated with new
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…