mercredi 27 septembre 2017

Is there any point in using `override` when overriding a pure virtual function?

For example:

class Base {
  virtual my_function() = 0;
};

class Derived : Base {
  my_function() override;
};

From what I read, the override keyword is used to make sure that we have the correct signature in the function that we are overriding, and it seems to be its only use.

However, in the case of a pure virtual function, the compiler would throw an error if we used an incorrect signature in the Derived class (or Base class, depending on how one see things). So, is there any point in adding override at the end of Derived::my_function() declaration?

Aucun commentaire:

Enregistrer un commentaire