I for one really hate destructors. They mean you can never tell what `delete` does. I remember a nasty double-free bug I had because of that.
I for one really hate destructors. They mean you can never tell what `delete` does. I remember a nasty double-free bug I had because of that.
> They mean you can never tell what `delete` does.
Can you elaborate on this? A destructor is a function that's built into an object. It's really not more complicated than that. If malloc/free are functions that should be used in pairs, then the constructor/destructor pair tries to provide a convenient and structured way to know where malloc/free go. You would call new in the constructor and delete in the destructor.
I'm curious to know what you prefer?
Somewhere down the line these other objects are freed again, causing double free.
It therefore still calls the destructor.
So this has literally no bearing on the problem. It doesn't help at all.