Does delete on a pointer to a subclass call the base class destructor?

前端 未结 11 2175
面向向阳花
面向向阳花 2020-11-27 09:16

I have an class A which uses a heap memory allocation for one of its fields. Class A is instantiated and stored as a pointer field in another class (clas

11条回答
  •  借酒劲吻你
    2020-11-27 09:44

    I was wondering why my class' destructor was not called. The reason was that I had forgot to include definition of that class (#include "class.h"). I only had a declaration like "class A;" and the compiler was happy with it and let me call "delete".

提交回复
热议问题