[ create a new paste ] login | about

Link: http://codepad.org/2UxxGaH5    [ raw code | output | fork ]

C++, pasted on Mar 10:
class xyz;

struct CDetail {
  CDetail() : a (42) {}
  int a, b, c; 
  std::set<int> mySet;
  xyz *some_private_ptr;
};

struct C : private CDetail {
protected:
  using CDetail::a;
};

struct D : C {
  void f() {
    cout << a;
  }
};

int main() {
  D d;
  d.f();  // D can access 'a'
  //cout << d.a;  // main cannot access 'a'
  return 0;
}


Output:
1
42


Create a new paste based on this one


Comments: