I was reading a question on SO and in one of the answers, it has been mentioned as:
If no unambiguous matching deallocation function can be found, propagating the exception does not cause the object’s memory to be freed.
So, if I just overload my new
operator and not the delete
operator, would any default delete
operator be created and called; or, do I have to also write the delete
operator explicitly.
What this means is that if you overload operator new with extra arguments, and not the corresponding delete with extra arguments, if an exception occurs in a constructor, no delete operator will be called. On the other hand, if you're overloading the basic new (with no extra arguments), and an exception occurs, delete with no extra argument will be called, and that will be the default operator delete if you have not overloaded it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With