Answers for "final function"

C++
1

final method meaning

When a METHOD is declared with final keyword, it is called a final method. 
A final method cannot be OVERRIDEN.
when a CLASS is declared final then it cant be INHERITED.
when a VARIABLE is declared final its value cant be CHANGED.
Posted by: Guest on May-26-2021
1

c++ final class

struct Base
{
    virtual void foo();
};
 
struct A : Base
{
    void foo() final; // Base::foo is overridden and A::foo is the final override
    void bar() final; // Error: bar cannot be final as it is non-virtual
};
 
struct B final : A // struct B is final
{
    void foo() override; // Error: foo cannot be overridden as it is final in A
};
 
struct C : B // Error: B is final
{
};
Posted by: Guest on December-04-2020

Browse Popular Code Answers by Language