To answer your question:
'imagine that the ptr points to some memory address which I want to check in the destructor of some other static class'
The answer is yes. You can see the value of the pointer (address).
You can see the contents if you did not call delete on the pointer.
Static function variables behave the same way as class static variables and global variables ( aka not local static), since destructors will be called in the opposite order of creation. Integers, float, and pointers (PODs) have no destructors, so nothing happens to them until processes are deleted.
POD objects: data can safely refer to the destructor of other objects (even global ones).
Other static objects (i.e. those that have destructors): In general, it is unsafe to access these objects after the main () exit, because the order of destruction is unknown (this is the opposite of the order of creation, but the order of creation is complex: Construction order ) . This can be done, but you must take explicit precautions to make sure that the object is still alive.
Note: not local static:
The memory will always be there, the object will simply be invalid after the destructor is called (the POD note does not have a destructor).
Note: Stack:
Valid only until the area in which they are declared is declared.
After the stack pops up, the page of memory on which it resides can potentially be reset, which will lead to SEG errors if you try to access it.
Note: Heap:
Valid until you name delete on the pointer that allocated it.
After the pointer is deleted, the value is potentially random, since it can be reused. Potentially, the page on which the memory was turned on can also be deleted. Any access to the dropped page will result in a SEG error.
source share