The question is pretty simple, what's the difference in using final like this,
final
class Base { public: Base() {} virtual ~Base() {} virtual void Initialize() {} }; class Derived final : public Base { public: Derived() {} ~Derived() {} virtual void Initialize() override {} };
And using override final like this,
override final
class Base { public: Base() {} virtual ~Base() {} virtual void Initialize() {} }; class Derived : public Base { public: Derived() {} ~Derived() {} virtual void Initialize() override final {} };
The first case locks the class. The following would cause an error:
class Derived2 : public Derived{};
The second forbids any class that inherits from it to redefine the finalmethod.
2.1m questions
2.1m answers
60 comments
57.0k users