override
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

override

override indicates that a member of a managed type must override a base class or a base interface member. If there is no member to override, the compiler will generate an error.

override is also valid when compiling for native targets (without /clr). See Override Specifiers and Native Compilations for more information.

override is a context-sensitive keyword. See Context-Sensitive Keywords for more information.

// override_keyword.cpp
// compile with: /clr /c
ref struct I1 {
   virtual void f();
};

ref struct X : public I1 {
   virtual void f() override {}
};

This sample shows that override can also be used in native compilations.

// override_keyword_2.cpp
// compile with: /c
struct I1 {
   virtual void f();
};

struct X : public I1 {
   virtual void f() override {}
};

Compiler option: /clr

Show:
© 2016 Microsoft