Behaviour of malloc with delete in C++

This is undefined behaviour, as there’s no way to reliably prove that memory behind the pointer was allocated correctly (i.e. by new for delete or new[] for delete[]). It’s your job to ensure things like that don’t happen. It’s simple when you use right tools, namely smart pointers. Whenever you say delete, you’re doing it … Read more

Why I can access member functions even after the object was deleted?

So, my question is, why I’m still able to call Go_XXX_Your_Self() and Identify_Your_Self() even after the object was deleted? Because of undefined behavior. Is this how it works in C++? (is there even after you delete it?) Because of undefined behavior. There is no guarantee that it will work the same on other implementations. Again, … Read more