Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Warning (level 1) C4486

Error Message

'function' : a private virtual method of a ref class or value class should be marked 'sealed'

Since a private virtual member function of a managed class or struct cannot be accessed or overridden, it should be marked sealed.

Example

The following sample generates C4486.

// C4486.cpp
// compile with: /clr /c /W1
ref class B {
private:
   virtual void f() {}   // C4486
   virtual void f1() sealed {}   // OK
};

The following sample shows one possible use of a private sealed, virtual function.

// C4486_b.cpp
// compile with: /clr /c
ref class B {};

ref class D : B {};

interface class I {
   B^ mf();
};

ref class E : I {
private:
   virtual B^ g() sealed = I::mf {
      return gcnew B;
   }

public:
   virtual D^ mf() {
      return gcnew D;
   }
};

Community Additions

ADD
Show:
© 2015 Microsoft