override specifier
Da cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Especifica que uma função virtual substitui outra função virtual.
Original:
Specifies that a função virtual overrides another virtual function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Índice |
[editar] Sintaxe
function_declaration override ;
|
|||||||||
Esta seção está incompleta Motivo: function_declaration is probably wrong terminology |
[editar] Explicação
Em uma declaração de método,
override
especifica que a função deve ser substituir um método de classe base.Original:
In a method declaration,
override
specifies that the function must be overriding a base class method.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
override é um identificador com um significado especial quando usado após declaração da função, caso contrário não é reservado.
Original:
override is an identifier with a special meaning when used after function declaration, otherwise it's not reserved.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[editar] Exemplo
struct A { virtual void foo(); void bar(); }; struct B : A { void foo() const override; // Error: Has a different signature from A::foo void foo() override; // OK: base class contains a virtual function with the same signature void bar() override; // Error: B::bar doesn't override because A::bar is not virtual };
[editar] Veja também
- final de especificador (desde C++11)