mercredi 29 novembre 2017

May a destructor be final?

Does the C++ standard allow a destructor to be declared as final? Like this:

 class Derived: public Base
 {
      ...
      virtual ~Derived() final;
 }

And if so, does that prevent the declaration of a derived class:

 class FurtherDerived: public Derived {// allowed?
 }

If it is allowed, is a compiler likely to issue a warning? Is declaring a destructor to be final a workable idiom for indicating that a class is not intended to be used as a base class?

Aucun commentaire:

Enregistrer un commentaire