#include <iostream> using namespace std; class A { public: int a; A() { a=2; } ~A() { a=1; } }; int main() { A * aa = new A(); delete aa; if (aa) cout<< aa->a; else cout<<"123"; } I create a pointer to an instance of the class, call the constructor, the variable "a" contains the number 2. I call the destructor (in which this "a" should become equal to 1). At first I put check whether there is a pointer on a class copy. It turned out that not only does it exist after the destructor, the number 0 also lies in "a". Does it mean that zeros start to lie in the memory, but is it still occupied by the program? How to remove from memory the entire instance of the class? If I replace the reference to the class (in this case, "aa") with the missing one, then (logically) it will not release the memory, but will not allow me to manage this memory anymore via this link.
delete, the pointer variable should be reset ... I wonder where its "legs grow from"? - Harrydelete aaonly deleted the object the pointer pointed to.delete aadoes nothing with the pointer itself. Your pointer is a local variable. It will exist until the end of the block. - AnT