From Jason Turner

[class.protected]

Diff to HTML by rtfpessoa

tmp/tmp2737sv82/{from.md → to.md} RENAMED
@@ -9,10 +9,12 @@ some class `C`. If the access is to form a pointer to member (
9
  [[expr.unary.op]]), the *nested-name-specifier* shall denote `C` or a
10
  class derived from `C`. All other accesses involve a (possibly implicit)
11
  object expression ([[expr.ref]]). In this case, the class of the object
12
  expression shall be `C` or a class derived from `C`.
13
 
 
 
14
  ``` cpp
15
  class B {
16
  protected:
17
  int i;
18
  static int j;
@@ -28,15 +30,14 @@ class D2 : public B {
28
 
29
  void fr(B* pb, D1* p1, D2* p2) {
30
  pb->i = 1; // ill-formed
31
  p1->i = 2; // ill-formed
32
  p2->i = 3; // OK (access through a D2)
33
- p2->B::i = 4; // OK (access through a D2, even though
34
- // naming class is B)
35
  int B::* pmi_B = &B::i; // ill-formed
36
  int B::* pmi_B2 = &D2::i; // OK (type of &D2::i is int B::*)
37
- B::j = 5; // OK (because refers to static member)
38
  D2::j = 6; // OK (because refers to static member)
39
  }
40
 
41
  void D2::mem(B* pb, D1* p1) {
42
  pb->i = 1; // ill-formed
@@ -54,5 +55,7 @@ void g(B* pb, D1* p1, D2* p2) {
54
  p1->i = 2; // ill-formed
55
  p2->i = 3; // ill-formed
56
  }
57
  ```
58
 
 
 
 
9
  [[expr.unary.op]]), the *nested-name-specifier* shall denote `C` or a
10
  class derived from `C`. All other accesses involve a (possibly implicit)
11
  object expression ([[expr.ref]]). In this case, the class of the object
12
  expression shall be `C` or a class derived from `C`.
13
 
14
+ [*Example 1*:
15
+
16
  ``` cpp
17
  class B {
18
  protected:
19
  int i;
20
  static int j;
 
30
 
31
  void fr(B* pb, D1* p1, D2* p2) {
32
  pb->i = 1; // ill-formed
33
  p1->i = 2; // ill-formed
34
  p2->i = 3; // OK (access through a D2)
35
+ p2->B::i = 4; // OK (access through a D2, even though naming class is B)
 
36
  int B::* pmi_B = &B::i; // ill-formed
37
  int B::* pmi_B2 = &D2::i; // OK (type of &D2::i is int B::*)
38
+ B::j = 5; // ill-formed (not a friend of naming class B)
39
  D2::j = 6; // OK (because refers to static member)
40
  }
41
 
42
  void D2::mem(B* pb, D1* p1) {
43
  pb->i = 1; // ill-formed
 
55
  p1->i = 2; // ill-formed
56
  p2->i = 3; // ill-formed
57
  }
58
  ```
59
 
60
+ — *end example*]
61
+