virtual function declared non-virtual in a derived class

后端 未结 5 2407
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-19 12:56

If a function is declared non-virtual in a derived class when the base class function was virutal, why does it invoke a vtable lookup on calling the function on its pointer? The

5条回答
  •  野的像风
    2021-02-19 13:29

    When a class inherits a virtual function, any new, overriding declaration of that function will automatically be made virtual, even if the virtual keyword is not used.

提交回复
热议问题