tmp/tmpd1grp_rn/{from.md → to.md}
RENAMED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
-
## Accessibility of base classes and base class members <a id="class.access.base">[[class.access.base]]</a>
|
| 2 |
|
| 3 |
-
If a class is declared to be a base class
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
|
| 15 |
In the absence of an *access-specifier* for a base class, `public` is
|
| 16 |
assumed when the derived class is defined with the *class-key* `struct`
|
| 17 |
and `private` is assumed when the class is defined with the *class-key*
|
| 18 |
`class`.
|
|
@@ -38,14 +38,15 @@ Here `B` is a public base of `D2`, `D4`, and `D6`, a private base of
|
|
| 38 |
|
| 39 |
[*Note 1*:
|
| 40 |
|
| 41 |
A member of a private base class might be inaccessible as an inherited
|
| 42 |
member name, but accessible directly. Because of the rules on pointer
|
| 43 |
-
conversions
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
class B {
|
| 50 |
public:
|
| 51 |
int mi; // non-static member
|
|
@@ -117,12 +118,12 @@ immediate base class of `X`. — *end note*]
|
|
| 117 |
The access to a member is affected by the class in which the member is
|
| 118 |
named. This naming class is the class in which the member name was
|
| 119 |
looked up and found.
|
| 120 |
|
| 121 |
[*Note 3*: This class can be explicit, e.g., when a *qualified-id* is
|
| 122 |
-
used, or implicit, e.g., when a class member access operator
|
| 123 |
-
[[expr.ref]]
|
| 124 |
added). If both a class member access operator and a *qualified-id* are
|
| 125 |
used to name the member (as in `p->T::m`), the class naming the member
|
| 126 |
is the class denoted by the *nested-name-specifier* of the
|
| 127 |
*qualified-id* (that is, `T`). — *end note*]
|
| 128 |
|
|
|
|
| 1 |
+
### Accessibility of base classes and base class members <a id="class.access.base">[[class.access.base]]</a>
|
| 2 |
|
| 3 |
+
If a class is declared to be a base class [[class.derived]] for another
|
| 4 |
+
class using the `public` access specifier, the public members of the
|
| 5 |
+
base class are accessible as public members of the derived class and
|
| 6 |
+
protected members of the base class are accessible as protected members
|
| 7 |
+
of the derived class. If a class is declared to be a base class for
|
| 8 |
+
another class using the `protected` access specifier, the public and
|
| 9 |
+
protected members of the base class are accessible as protected members
|
| 10 |
+
of the derived class. If a class is declared to be a base class for
|
| 11 |
+
another class using the `private` access specifier, the public and
|
| 12 |
+
protected members of the base class are accessible as private members of
|
| 13 |
+
the derived class.[^12]
|
| 14 |
|
| 15 |
In the absence of an *access-specifier* for a base class, `public` is
|
| 16 |
assumed when the derived class is defined with the *class-key* `struct`
|
| 17 |
and `private` is assumed when the class is defined with the *class-key*
|
| 18 |
`class`.
|
|
|
|
| 38 |
|
| 39 |
[*Note 1*:
|
| 40 |
|
| 41 |
A member of a private base class might be inaccessible as an inherited
|
| 42 |
member name, but accessible directly. Because of the rules on pointer
|
| 43 |
+
conversions [[conv.ptr]] and explicit casts ([[expr.type.conv]],
|
| 44 |
+
[[expr.static.cast]], [[expr.cast]]), a conversion from a pointer to a
|
| 45 |
+
derived class to a pointer to an inaccessible base class might be
|
| 46 |
+
ill-formed if an implicit conversion is used, but well-formed if an
|
| 47 |
+
explicit cast is used. For example,
|
| 48 |
|
| 49 |
``` cpp
|
| 50 |
class B {
|
| 51 |
public:
|
| 52 |
int mi; // non-static member
|
|
|
|
| 118 |
The access to a member is affected by the class in which the member is
|
| 119 |
named. This naming class is the class in which the member name was
|
| 120 |
looked up and found.
|
| 121 |
|
| 122 |
[*Note 3*: This class can be explicit, e.g., when a *qualified-id* is
|
| 123 |
+
used, or implicit, e.g., when a class member access operator
|
| 124 |
+
[[expr.ref]] is used (including cases where an implicit “`this->`” is
|
| 125 |
added). If both a class member access operator and a *qualified-id* are
|
| 126 |
used to name the member (as in `p->T::m`), the class naming the member
|
| 127 |
is the class denoted by the *nested-name-specifier* of the
|
| 128 |
*qualified-id* (that is, `T`). — *end note*]
|
| 129 |
|