Does final imply override?

后端 未结 5 1806
别跟我提以往
别跟我提以往 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:03

    final does not necessarily imply that the function is overridden. It's perfectly valid (if of somewhat dubious value) to declare a virtual function as final on its first declaration in the inheritance hierarchy.

    One reason I can think of to create a virtual and immediately final function is if you want to prevent a derived class from giving the same name & parameters a different meaning.

提交回复
热议问题