共用方式為


編譯器警告 (層級 3) C4265

'class' : 類別有虛擬函式,但解構函式不是虛擬的

若類別具有虛擬函式但同時也具有非虛擬的解構函式,當透過基底類別指標終結此類別時,則可能無法正確終結該型別物件。

此警告在預設情況下為關閉的。 如需詳細資訊,請參閱預設為關閉的編譯器警告

下列範例會產生 C4265:

// C4265.cpp
// compile with: /W3 /c
#pragma warning(default : 4265)
class B
{
public:
   virtual void vmf();

   ~B();
   // try the following line instead
   // virtual ~B();
};   // C4265

int main()
{
   B b;
}