Does final imply override?

后端 未结 5 1797
别跟我提以往
别跟我提以往 2021-01-31 01:28

As I understand it, the override keyword states that a given declaration implements a base virtual method, and the compilation should fail if there is

5条回答
  •  离开以前
    2021-01-31 02:01

    No final does not necessarily imply override. In fact, you could declare a virtual function that you immediately declare final see here. The final keyword simply states that no derived class can create an override of this function.

    The override keyword is important in that it enforces that you are indeed actually overriding a virtual function (instead of declaring a new unrelated one). See this post regarding override

    So long story short, they each serve their own particular purpose, and it is often correct to use both.

提交回复
热议问题