What happens when you deallocate a pointer twice or more in C++?

You get undefined behaviour if you try to delete an object through a pointer more than once.

This means that pretty much anything can happen from ‘appearing to work’ to ‘crashing’ or something completely random.

Leave a Comment