order of destruction using virtual

前端 未结 8 1288
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 00:35

Can some one please help what the order of destruction is when I am using virtual functions. Does it start with the base class and then derived class?

8条回答
  •  庸人自扰
    2021-02-06 01:20

    The destruction order is the construction order backwards. I've recently made a small tool to display the construction order for any hierarchy. Look here:

    • Where is the "virtual" keyword necessary in a complex multiple inheritance hierarchy?

    In the diagrams, the nodes with the smaller numbers are constructed first and destructed last.

提交回复
热议问题