GNU compiler warning “class has virtual functions but non-virtual destructor”

前端 未结 7 2431
有刺的猬
有刺的猬 2020-12-13 06:08

I have defined an interface in C++, i.e. a class containing only pure virtual functions.

I want to explicitly forbid users of the interface to delete the object thro

7条回答
  •  我在风中等你
    2020-12-13 06:14

    If the destructor is virtual it makes sure that the base class destructor is also called fore doing the cleanup, otherwise some leaks can result from that code. So you should make sure that the program has no such warnings (prefferably no warnings at all).

提交回复
热议问题