I need to declare a finalize() finalization method for all descendants of the Base base class that should be called at the time of destruction, and my intention was to call pure virtual void Base::finalize() = 0 from ~Base() , but C ++ forbids such a thing. So my question is:
How can we get descendants to do some final work in a right and predefined way?
This code cannot be compiled:
If I make Base::finalize() not pure virtual, it is called from ~Base() without sending it to the child, since it has already been destroyed.
I can call finalize () from the child destructor, but the question is how to get this done. In other words, my question is: is it possible to oblige people who will write descendants of the base class to use the finalization method, well, differently than to comment on it in the documentation? :)
Tim kachko
source share