Question about pure virtual destructor

前端 未结 4 1570
时光说笑
时光说笑 2020-12-02 00:24

If we define a abstract class which has a pure virtual destructor, why do we have to give a definition of a destructor in the abstract class?

4条回答
  •  时光说笑
    2020-12-02 00:53

    Only a virtual dtor can be declared as pure. But then, since you add a declaration, you must implement the body of the dtor. As already mentioned, the destructors call their parent dtor, all up to the chain of inheritance.

提交回复
热议问题