vendredi 7 février 2020

final class and final member functions

Say I have the base class:

struct Base
{
    virtual void foo();
};

and the derived class is final struct A final : public Base. Does it make sense to make the member functions final as well? I've seen in several places e.g.

struct A final : public Base {
    void foo() final;
}

I am not sure it provides any value in this case as if the class itself is final I guess all the member functions are final by default as well. Am I missing something? Are there any guidelines?

Aucun commentaire:

Enregistrer un commentaire