lundi 13 juillet 2020

What is the best practice for derived class destruction?

We know that the base class destructor is marked virtual for proper destruction of derived class instances as the base type pointers. Then what are the differences between the following derived class destructor practices?

  1. Simple destructor: ~Derived();
  2. Destructor with override: ~Derived() override;
  3. Default destructor with override: ~Derived() override = default;
  4. Virtual destructor: virtual ~Derived() override = default;

Also is there a known best practice?

Aucun commentaire:

Enregistrer un commentaire