So, I am moving from the “owned” object model to the “managed” object model in the project that I am doing. Currently to create a new Thing one
Thing *thing = new Thing();
and get rid of it and destroy its owner
delete thing
Now there is a lot of “delete thing”, and many of them are removed from the superclass of the Thing class, since the superclass has a virtual destructor.
Now in the managed model there is a base class with a virtual destructor that the manager will delete. The user must call "release" on it DO NOT delete.
Therefore, I would like to somehow reject the “delete thing” as a compile-time error during compilation. Creating a destructor is “protected”, it does not seem to work because of a virtual destructor based on it. And it should be at least protected for subclasses (I think).
Does anyone have any idea?
source
share