title | ms.custom | ms.date | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
override (C++ Component Extensions) | Microsoft Docs |
11/04/2016 |
|
language-reference |
|
|
34d19257-1686-4fcd-96f5-af07c70ba914 |
19 |
mikeblome |
mblome |
ghogen |
The override
context-sensitive keyword indicates that a member of a type overrides a base class or a base interface member.
The override
keyword is valid when compiling for native targets (default compiler option), Windows Runtime targets (/ZW compiler option), or common language runtime targets (/clr compiler option).
For more information about override specifiers, see override Specifier and Override Specifiers and Native Compilations.
For more information about context-sensitive keywords, see Context-Sensitive Keywords.
Example
The following code example shows that override
can also be used in native compilations.
// override_keyword_1.cpp
// compile with: /c
struct I1 {
virtual void f();
};
struct X : public I1 {
virtual void f() override {}
};
Example
The following code example shows that override
can be used in Windows Runtime compilations.
// override_keyword_2.cpp
// compile with: /ZW /c
ref struct I1 {
virtual void f();
};
ref struct X : public I1 {
virtual void f() override {}
};
Requirements
Compiler option: /ZW
Example
The following code example shows that override
can be used in common language runtime compilations.
// override_keyword_3.cpp
// compile with: /clr /c
ref struct I1 {
virtual void f();
};
ref struct X : public I1 {
virtual void f() override {}
};
Requirements
Compiler option: /clr