final specifier
来自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. |
指定一個虛函數不能在派生類中被覆蓋或一個類不能被繼承
Original:
Specifies that a 虛函數 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.
目錄 |
[编辑] 語法
function_declaration final ;
|
|||||||||
class class_name final base_classes
|
|||||||||
| 本節是不完整的 原因: function_declaration is probably wrong terminology |
[编辑] 解釋
使用時,在一個虛擬的函數聲明,
final指定的功能可能無法派生類中重寫.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是一個具有特殊意義的一個成員函數的聲明或類頭在使用時的標識符。在其他情況下,它是沒有保留,並且可以使用名稱的對象和功能.
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.
[编辑] 為例
struct A { virtual void 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 { };
[编辑] 另請參閱
- 覆蓋說明 (C++11 起)

