class abc {
int x ;
};
int main()
{
abc *A = new abc ;
cout<< static_cast(A) << endl ;
delete A ;
cout<< static_cast&
Why should this not happen? Once you've deleted memory at a particular address, the memory manager is perfectly at liberty to re-use that address the next time you ask for new memory. Indeed this is a very common optimisation used by memory managers. They keep track of recently freed blocks and hand them back to the next client that requests a block of that size.
Another way to look at this would be to consider what would happen if freed addresses were never re-used. If that were to happen then eventually, after enough allocation/deallocation cycles, there would be no address space left. Indeed, if re-use never happened then there would be no point at all in deallocating memory. So yes, do expect that when you deallocate memory, that memory address will be re-used.