final specifier
De 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. |
Indique qu'une fonction virtuelle ne peut pas être substituée dans une classe dérivée ou qu'une classe ne peut pas être héritée
Original:
Specifies that a fonction virtuelle can not be overridden in a derived class or that a class cannot be inherited
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.
Sommaire |
[modifier]Syntaxe
function_declarationfinal ; | |||||||||
class class_namefinal base_classes | |||||||||
This section is incomplete Reason: function_declaration is probably wrong terminology |
[modifier]Explication
Lorsqu'il est utilisé dans une déclaration de fonction virtuelle,
final
spécifie que la fonction ne peut pas être remplacée par des classes dérivées .Original:
When used in a virtual function declaration,
final
specifies that the function may not be overridden by derived classes.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.
final est un identifiant avec une signification particulière lorsqu'il est utilisé dans une déclaration de fonction membre ou chef de classe. Dans d'autres contextes ne sont pas réservés et peuvent être utilisés pour nommer des objets et des fonctions .
Original:
final is an identifier with a special meaning when used in a member function declaration or class head. In other contexts it is not reserved and may be used to name objects and functions.
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.
[modifier]Exemple
struct A {virtualvoid foo() final;}; struct B final : A {void foo();// Error: foo cannot be overridden as it's final in A}; struct C : B // Error: B is final{};
[modifier]Voir aussi
- remplacer spécificateur (depuis C++11)