I am aware what the final
method annotation in C++ (since C++11) does from a language point-of-view.
class Base {
virtual void method();
};
class Locked : public Base {
virtual void method() final;
};
Any class deriving from Locked
can not override method
anymore.
But what does it say about the API, the contract from an OOP point of view? As already asked for Java, what must I be aware of, as a class author of Locked
, about the design of the whole class now, what do I promise?
For example: I could imagine that by annotating with final
I am saying that "this methods behavior does not change". But what if I call other methods inside method()
? If they can be overridden, how can I promise that? So, does annotating with final mean, I must not use other overridable methods inside that method, strictly speaking, from an OOP point-of-view? Or other design constraints?