Why don't STL containers have virtual destructors?

后端 未结 9 2208
时光取名叫无心
时光取名叫无心 2020-11-28 07:54

Does anyone know why the STL containers don\'t have virtual destructors?

As far as I can tell, the only benefits are:

  • it reduces the size of an insta
9条回答
  •  借酒劲吻你
    2020-11-28 08:02

    A virtual destructor is only useful for inheritance scenarios. STL containers are not designed to be inherited from (nor is it a supported scenario). Hence they don't have virtual destructors.

提交回复
热议问题