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

前端 未结 7 2345
有刺的猬
有刺的猬 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:11

    If you insist on doing this, go ahead and pass -Wno-non-virtual-dtor to GCC. This warning doesn't seem to be turned on by default, so you must have enabled it with -Wall or -Weffc++. However, I think it's a useful warning, because in most situations this would be a bug.

提交回复
热议问题