Why base class destructor (virtual) is called when a derived class object is deleted?

后端 未结 7 803
再見小時候
再見小時候 2020-12-13 13:45

A difference between a destructor (of course also the constructor) and other member functions is that, if a regular member function has a body at the derived class, only the

7条回答
  •  我在风中等你
    2020-12-13 14:37

    When any object is destroyed, destructors run for all sub-objects. This includes both reuse by containment and reuse by inheritance.

提交回复
热议问题