Deriving a class may be forbidden with final
specifier. Let's declare a final class:
class A final {
};
Now any attempt to subclass it will cause a compilation error:
// Compilation error: cannot derive from final class:
class B : public A {
};
Final class may appear anywhere in class hierarchy:
class A {
};
// OK.
class B final : public A {
};
// Compilation error: cannot derive from final class B.
class C : public B {
};