Destructor being called twice when being explicitly invoked

It happens because you told it to happen. The destructor for an automatic variable is always called when the variable goes out of scope. You also called it. That’s two calls total.

Calling an object’s destructor does not signal to C++ not to call it again, since in normal execution there is no need to keep track.

The solution is to never manually call your destructor.

Leave a Comment