Let's say I have the following base class:
class Base {
public:
virtual void f() {};
};
If I want to write a class that will override the f()
and will not allow to override it to it's derived classes can write it using following approaches:
Approach 1:
class Derived : public Base {
public:
virtual void f() override final {};
};
Approach 2:
class Derived : public Base {
public:
void f() final {};
};
Approach 1
is a fully detailed when Approach 2
more compact and final
still says that f()
is actually virtual and overrides the base class method.
Which one approach is more appropriate?
See Question&Answers more detail:os