Compiler Warning (level 1) C4486
Collapse the table of content
Expand the table of content
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. ArchiveDisclaimer

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.


The following sample generates C4486.

// C4486.cpp
// compile with: /clr /c /W1
ref class B {
   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 {
   virtual B^ g() sealed = I::mf {
      return gcnew B;

   virtual D^ mf() {
      return gcnew D;
© 2016 Microsoft