tmp/tmp0hzk2w1k/{from.md → to.md}
RENAMED
|
@@ -25,11 +25,11 @@ base-specifier:
|
|
| 25 |
|
| 26 |
``` bnf
|
| 27 |
class-or-decltype:
|
| 28 |
nested-name-specifierₒₚₜ type-name
|
| 29 |
nested-name-specifier template simple-template-id
|
| 30 |
-
|
| 31 |
```
|
| 32 |
|
| 33 |
``` bnf
|
| 34 |
access-specifier:
|
| 35 |
private
|
|
@@ -44,17 +44,20 @@ The component names of a *class-or-decltype* are those of its
|
|
| 44 |
*nested-name-specifier*, *type-name*, and/or *simple-template-id*. A
|
| 45 |
*class-or-decltype* shall denote a (possibly cv-qualified) class type
|
| 46 |
that is not an incompletely defined class [[class.mem]]; any
|
| 47 |
cv-qualifiers are ignored. The class denoted by the *class-or-decltype*
|
| 48 |
of a *base-specifier* is called a *direct base class* for the class
|
| 49 |
-
being defined
|
| 50 |
-
*
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
base class
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
[*Note 1*: See [[class.access]] for the meaning of
|
| 58 |
*access-specifier*. — *end note*]
|
| 59 |
|
| 60 |
Members of a base class are also members of the derived class.
|
|
@@ -265,29 +268,29 @@ a distinct `B` subobject within the object of type `AA`. Given the class
|
|
| 265 |
|
| 266 |
### Virtual functions <a id="class.virtual">[[class.virtual]]</a>
|
| 267 |
|
| 268 |
A non-static member function is a *virtual function* if it is first
|
| 269 |
declared with the keyword `virtual` or if it overrides a virtual member
|
| 270 |
-
function declared in a base class (see below).[^
|
| 271 |
|
| 272 |
[*Note 1*: Virtual functions support dynamic binding and
|
| 273 |
object-oriented programming. — *end note*]
|
| 274 |
|
| 275 |
A class with a virtual member function is called a
|
| 276 |
-
*polymorphic class*.[^
|
| 277 |
|
| 278 |
If a virtual member function F is declared in a class B, and, in a class
|
| 279 |
D derived (directly or indirectly) from B, a declaration of a member
|
| 280 |
function G corresponds [[basic.scope.scope]] to a declaration of F,
|
| 281 |
-
ignoring trailing *requires-clause*s, then G *overrides*[^
|
| 282 |
|
| 283 |
-
F. For convenience we say that any virtual function overrides itself. A
|
| 284 |
virtual member function V of a class object S is a *final overrider*
|
| 285 |
unless the most derived class [[intro.object]] of which S is a base
|
| 286 |
class subobject (if any) has another member function that overrides V.
|
| 287 |
In a derived class, if a virtual member function of a base class
|
| 288 |
-
subobject has more than one final overrider the program is ill-formed.
|
| 289 |
|
| 290 |
[*Example 1*:
|
| 291 |
|
| 292 |
``` cpp
|
| 293 |
struct A {
|
|
@@ -405,11 +408,11 @@ the return type of the overridden function or *covariant* with the
|
|
| 405 |
classes of the functions. If a function `D::f` overrides a function
|
| 406 |
`B::f`, the return types of the functions are covariant if they satisfy
|
| 407 |
the following criteria:
|
| 408 |
|
| 409 |
- both are pointers to classes, both are lvalue references to classes,
|
| 410 |
-
or both are rvalue references to classes[^
|
| 411 |
- the class in the return type of `B::f` is the same class as the class
|
| 412 |
in the return type of `D::f`, or is an unambiguous and accessible
|
| 413 |
direct or indirect base class of the class in the return type of
|
| 414 |
`D::f`
|
| 415 |
- both pointers or references have the same cv-qualification and the
|
|
|
|
| 25 |
|
| 26 |
``` bnf
|
| 27 |
class-or-decltype:
|
| 28 |
nested-name-specifierₒₚₜ type-name
|
| 29 |
nested-name-specifier template simple-template-id
|
| 30 |
+
computed-type-specifier
|
| 31 |
```
|
| 32 |
|
| 33 |
``` bnf
|
| 34 |
access-specifier:
|
| 35 |
private
|
|
|
|
| 44 |
*nested-name-specifier*, *type-name*, and/or *simple-template-id*. A
|
| 45 |
*class-or-decltype* shall denote a (possibly cv-qualified) class type
|
| 46 |
that is not an incompletely defined class [[class.mem]]; any
|
| 47 |
cv-qualifiers are ignored. The class denoted by the *class-or-decltype*
|
| 48 |
of a *base-specifier* is called a *direct base class* for the class
|
| 49 |
+
being defined; for each such *base-specifier*, the corresponding
|
| 50 |
+
*direct base class relationship* is the ordered pair (`D`, `B`) where
|
| 51 |
+
`D` is the class being defined and `B` is the direct base class. The
|
| 52 |
+
lookup for the component name of the *type-name* or *simple-template-id*
|
| 53 |
+
is type-only [[basic.lookup]]. A class `B` is a base class of a class
|
| 54 |
+
`D` if it is a direct base class of `D` or a direct base class of one of
|
| 55 |
+
`D`’s base classes. A class is an *indirect base class* of another if it
|
| 56 |
+
is a base class but not a direct base class. A class is said to be
|
| 57 |
+
(directly or indirectly) *derived* from its (direct or indirect) base
|
| 58 |
+
classes.
|
| 59 |
|
| 60 |
[*Note 1*: See [[class.access]] for the meaning of
|
| 61 |
*access-specifier*. — *end note*]
|
| 62 |
|
| 63 |
Members of a base class are also members of the derived class.
|
|
|
|
| 268 |
|
| 269 |
### Virtual functions <a id="class.virtual">[[class.virtual]]</a>
|
| 270 |
|
| 271 |
A non-static member function is a *virtual function* if it is first
|
| 272 |
declared with the keyword `virtual` or if it overrides a virtual member
|
| 273 |
+
function declared in a base class (see below).[^5]
|
| 274 |
|
| 275 |
[*Note 1*: Virtual functions support dynamic binding and
|
| 276 |
object-oriented programming. — *end note*]
|
| 277 |
|
| 278 |
A class with a virtual member function is called a
|
| 279 |
+
*polymorphic class*.[^6]
|
| 280 |
|
| 281 |
If a virtual member function F is declared in a class B, and, in a class
|
| 282 |
D derived (directly or indirectly) from B, a declaration of a member
|
| 283 |
function G corresponds [[basic.scope.scope]] to a declaration of F,
|
| 284 |
+
ignoring trailing *requires-clause*s, then G *overrides*[^7]
|
| 285 |
|
| 286 |
+
F. For convenience, we say that any virtual function overrides itself. A
|
| 287 |
virtual member function V of a class object S is a *final overrider*
|
| 288 |
unless the most derived class [[intro.object]] of which S is a base
|
| 289 |
class subobject (if any) has another member function that overrides V.
|
| 290 |
In a derived class, if a virtual member function of a base class
|
| 291 |
+
subobject has more than one final overrider, the program is ill-formed.
|
| 292 |
|
| 293 |
[*Example 1*:
|
| 294 |
|
| 295 |
``` cpp
|
| 296 |
struct A {
|
|
|
|
| 408 |
classes of the functions. If a function `D::f` overrides a function
|
| 409 |
`B::f`, the return types of the functions are covariant if they satisfy
|
| 410 |
the following criteria:
|
| 411 |
|
| 412 |
- both are pointers to classes, both are lvalue references to classes,
|
| 413 |
+
or both are rvalue references to classes[^8]
|
| 414 |
- the class in the return type of `B::f` is the same class as the class
|
| 415 |
in the return type of `D::f`, or is an unambiguous and accessible
|
| 416 |
direct or indirect base class of the class in the return type of
|
| 417 |
`D::f`
|
| 418 |
- both pointers or references have the same cv-qualification and the
|