共用方式為


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.

Example

// 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 {}
};

See Also

Reference

Override Specifiers