In C++, is a function automatically virtual if it overrides a virtual function?

前端 未结 4 2026
清歌不尽
清歌不尽 2020-12-05 18:12

I would expect that if foo is declared in class D, but not marked virtual, then the following code would call the implementation of foo

4条回答
  •  悲哀的现实
    2020-12-05 19:12

    Quick answer may be no, but correct answer is yes

    C++ doesn't know about function hiding, so overriding virtual function without virtual keyword marks that function virtual too.

提交回复
热议问题