A virtual member function is used if it is not pure?

前端 未结 5 2149
长情又很酷
长情又很酷 2021-02-15 12:03

C++03 3.2.2 ...An object or non-overloaded function is used if its name appears in a potentially-evaluated expression. A virtual member function is used

5条回答
  •  忘了有多久
    2021-02-15 12:12

    The two clauses are not mutually exclusive. That a virtual function is used if it is not pure, does not mean that the converse holds. If a virtual function is pure it does not mean that it is necessarily not used. It may still be used "if its name appears in a potentially evaluated expression" such as in your example: A::f();.

提交回复
热议问题