Object *p = new Object();
delete p;
When I delete p, the object allocation on the heap is deleted. But what exactly happens to p itself? Is it deleted from the stack? or is it still in the stack and still contains the address of the memory that previously held Object?
pis still on the stack and holds the address of theObjectyou’ve just deleted. You are free to reusep, assigning it to point at other allocated data orNULL/nullptr.