问题描述:

This question already has an answer here:

  • Calling virtual function from destructor

    4 answers

网友答案:

When instantiating an object the base class gets initialized and then the subclass gets initialized. When destructing an object the subclass gets destructed and then the base class. After the subclass is destructed, its members and virtual methods are unavailable—there is no destroy() method to be invoked. I suggest you move the logic in the destroy() method to the subclass destructor.

相关阅读:
Top