A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4659/class.protected below:

[class.protected]

An additional access check beyond those described earlier in Clause [class.access] is applied when a non-static data member or non-static member function is a protected member of its naming class ([class.access.base])115 As described earlier, access to a protected member is granted because the reference occurs in a friend or member of some class C. If the access is to form a pointer to member ([expr.unary.op]), the nested-name-specifier shall denote C or a class derived from C. All other accesses involve a (possibly implicit) object expression. In this case, the class of the object expression shall be C or a class derived from C. [Example:

class B {
protected:
  int i;
  static int j;
};

class D1 : public B {
};

class D2 : public B {
  friend void fr(B*,D1*,D2*);
  void mem(B*,D1*);
};

void fr(B* pb, D1* p1, D2* p2) {
  pb->i = 1;                      p1->i = 2;                      p2->i = 3;                      p2->B::i = 4;                   int B::* pmi_B = &B::i;         int B::* pmi_B2 = &D2::i;       B::j = 5;                       D2::j = 6;                    }

void D2::mem(B* pb, D1* p1) {
  pb->i = 1;                      p1->i = 2;                      i = 3;                          B::i = 4;                       int B::* pmi_B = &B::i;         int B::* pmi_B2 = &D2::i;       j = 5;                          B::j = 6;                     }

void g(B* pb, D1* p1, D2* p2) {
  pb->i = 1;                      p1->i = 2;                      p2->i = 3;                    }

end example]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4