lundi 22 mai 2017

Should I reuse virtual when overriding in a sub-subclass?

I know I don't need to declare an overriding function in a subclass as virtual. But if I'm using a virtual function in a sub-subclass do I need to declare the subclass function as virtual?

struct Base
{
    virtual int foo();
};

struct Derived : Base
{
    virtual int foo() override
    {
       // ...
    }
};

struct DoubleDerived : Derived
{
    int foo() override
    {
       // ...
    }
};

Aucun commentaire:

Enregistrer un commentaire