1 | initial version |
One way to turn off the warning for delete-non-virtual-dtor is to use a pragma statement. For example, the following code disables the warning for MSVC compiler:
#pragma warning(disable: 4265)
class MyBaseClass
{
protected:
~MyBaseClass() {} // protected non-virtual destructor
};
#pragma warning(default: 4265)
This will suppress the warning for delete-non-virtual-dtor specifically for the MyBaseClass destructor. However, it is recommended to consider using a virtual destructor instead of a protected non-virtual destructor to avoid potential issues with object deletion in the future.