Export (0) Print
Expand All

override

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

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

Community Additions

ADD
Show:
© 2014 Microsoft