Is it possible to have a virtual delete operator? I’m not talking destructor, I mean the actual operator overload.
Minus the fact that it is (in most cases) a big bad idea to overload new and delete (Yes, I already know it’s heresy), I want to know what kind of implications come from using a virtual delete operator.
I’m thinking about trying to use a virtual delete, as sometimes I might have a child class that overloads delete, stored in a base class pointer. Technically, I don’t really ever see this case coming to too much fruition, unless I have a tree of different node types (potentially dangerous idea in the first place if you ask me).
I just want to know what would be the potential pros and cons of a virtual, or non virtual, delete operator override.
You can’t explicitly declare
operator deleteasvirtual.It is a static member function, even if you do not supply the keyword
static.But
operator deleteis already virtual in the sense that the one defined in the most derived class is used. You might choose to think of it as if it’s called by the destructor. It might even be. 😉