class System
{
public:
virtual ~System() final { Shutdown(); };
virtual void Shutdown() = 0;
}
class DerivedSystem
{
public:
virtual void Shutdown() override;
private:
Object* MySelfAllocatedObj;
}
Here is my use case,
I have a manager that holds a list of System* registered by various other "modules", each of those System* are actually derieved classes, unknown to the System Manager.
Those modules will Request a Shutdown() when their respective System* should end/die.
So, if one of those DerivedSystem has a MySelfAllocatedObj (ptr) and destroys it as part of Shutdown(), would my memory be cleaned properly using the current architecture?
I'm doing so to limit the number of "destruction" functions ie Destructor/Shutdown, but do not want to expose the destructor to the "module requesting that DerivedSystem)
Extra : What would happen if a DerievedSystem class was to declare a destructor?
Aucun commentaire:
Enregistrer un commentaire