Can the default destructor be generated as a virtual destructor automatically?

前端 未结 7 1528
轮回少年
轮回少年 2021-01-31 07:30

Can the default destructor be generated as a virtual destructor automatically?

If I define a base class but no default destructor, is there a default virtual destructor

相关标签:
7条回答
  • 2021-01-31 08:03

    No. There is a cost associated with making a method virtual, and C++ has a philosophy of not making you pay for things that you don't explicitly state that you want to use. If a virtual destructor would have been generated automatically, you would have been paying the price automatically.

    Why not just define an empty virtual destructor?

    0 讨论(0)
提交回复
热议问题