tmp/tmp5uqypij8/{from.md → to.md}
RENAMED
|
@@ -1,28 +1,28 @@
|
|
| 1 |
### Virtual functions <a id="class.virtual">[[class.virtual]]</a>
|
| 2 |
|
| 3 |
A non-static member function is a *virtual function* if it is first
|
| 4 |
declared with the keyword `virtual` or if it overrides a virtual member
|
| 5 |
-
function declared in a base class (see below).[^
|
| 6 |
|
| 7 |
[*Note 1*: Virtual functions support dynamic binding and
|
| 8 |
object-oriented programming. — *end note*]
|
| 9 |
|
| 10 |
A class with a virtual member function is called a
|
| 11 |
-
*polymorphic class*.[^
|
| 12 |
|
| 13 |
If a virtual member function F is declared in a class B, and, in a class
|
| 14 |
D derived (directly or indirectly) from B, a declaration of a member
|
| 15 |
function G corresponds [[basic.scope.scope]] to a declaration of F,
|
| 16 |
-
ignoring trailing *requires-clause*s, then G *overrides*[^
|
| 17 |
|
| 18 |
-
F. For convenience we say that any virtual function overrides itself. A
|
| 19 |
virtual member function V of a class object S is a *final overrider*
|
| 20 |
unless the most derived class [[intro.object]] of which S is a base
|
| 21 |
class subobject (if any) has another member function that overrides V.
|
| 22 |
In a derived class, if a virtual member function of a base class
|
| 23 |
-
subobject has more than one final overrider the program is ill-formed.
|
| 24 |
|
| 25 |
[*Example 1*:
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
struct A {
|
|
@@ -140,11 +140,11 @@ the return type of the overridden function or *covariant* with the
|
|
| 140 |
classes of the functions. If a function `D::f` overrides a function
|
| 141 |
`B::f`, the return types of the functions are covariant if they satisfy
|
| 142 |
the following criteria:
|
| 143 |
|
| 144 |
- both are pointers to classes, both are lvalue references to classes,
|
| 145 |
-
or both are rvalue references to classes[^
|
| 146 |
- the class in the return type of `B::f` is the same class as the class
|
| 147 |
in the return type of `D::f`, or is an unambiguous and accessible
|
| 148 |
direct or indirect base class of the class in the return type of
|
| 149 |
`D::f`
|
| 150 |
- both pointers or references have the same cv-qualification and the
|
|
|
|
| 1 |
### Virtual functions <a id="class.virtual">[[class.virtual]]</a>
|
| 2 |
|
| 3 |
A non-static member function is a *virtual function* if it is first
|
| 4 |
declared with the keyword `virtual` or if it overrides a virtual member
|
| 5 |
+
function declared in a base class (see below).[^5]
|
| 6 |
|
| 7 |
[*Note 1*: Virtual functions support dynamic binding and
|
| 8 |
object-oriented programming. — *end note*]
|
| 9 |
|
| 10 |
A class with a virtual member function is called a
|
| 11 |
+
*polymorphic class*.[^6]
|
| 12 |
|
| 13 |
If a virtual member function F is declared in a class B, and, in a class
|
| 14 |
D derived (directly or indirectly) from B, a declaration of a member
|
| 15 |
function G corresponds [[basic.scope.scope]] to a declaration of F,
|
| 16 |
+
ignoring trailing *requires-clause*s, then G *overrides*[^7]
|
| 17 |
|
| 18 |
+
F. For convenience, we say that any virtual function overrides itself. A
|
| 19 |
virtual member function V of a class object S is a *final overrider*
|
| 20 |
unless the most derived class [[intro.object]] of which S is a base
|
| 21 |
class subobject (if any) has another member function that overrides V.
|
| 22 |
In a derived class, if a virtual member function of a base class
|
| 23 |
+
subobject has more than one final overrider, the program is ill-formed.
|
| 24 |
|
| 25 |
[*Example 1*:
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
struct A {
|
|
|
|
| 140 |
classes of the functions. If a function `D::f` overrides a function
|
| 141 |
`B::f`, the return types of the functions are covariant if they satisfy
|
| 142 |
the following criteria:
|
| 143 |
|
| 144 |
- both are pointers to classes, both are lvalue references to classes,
|
| 145 |
+
or both are rvalue references to classes[^8]
|
| 146 |
- the class in the return type of `B::f` is the same class as the class
|
| 147 |
in the return type of `D::f`, or is an unambiguous and accessible
|
| 148 |
direct or indirect base class of the class in the return type of
|
| 149 |
`D::f`
|
| 150 |
- both pointers or references have the same cv-qualification and the
|