Why should the destructor of base classes be virtual?

前端 未结 5 1163
长情又很酷
长情又很酷 2021-02-05 19:14

in C++: Why should the destructor of base classes be virtual?

5条回答
  •  一个人的身影
    2021-02-05 19:41

    It should be virtual to ensure that the destructor of the inherited classes are the ones actually getting called at runtime instead of the base class destructor being called.

提交回复
热议问题