dimanche 30 avril 2017

Is the final function specifier redundant when using the final class specifier?

Is there any reason to specify a function as final when the class is already final? Or is that redundant?

class B
{
public:
    virtual void f();
};

class D final : public B
{
public:
    virtual void f() final; // Redundant final?
};

Would it be a good rule of thumb to say: Start with making the whole class final, and only switch to making individual functions final when you need to derive from the class and/or override specific functions?

Aucun commentaire:

Enregistrer un commentaire