xref: /openbsd-src/gnu/usr.bin/gcc/gcc/testsuite/g++.old-deja/g++.bob/protected1.C (revision c87b03e512fc05ed6e0222f6fb0ae86264b1d05b)
1 // Build don't link:
2 class A {
3 public:
4   int i;
A(int j)5   A(int j) : i(j){}
6 };
7 
8 class B : protected A {
9 public:
B(int j)10   B(int j) : A(j){}
f()11   void f(){
12     A k(*this);
13   }
14 };
15 
16 class C : protected B {
17 public:
C(int j)18   C(int j) : B(j){}
19   void f();
20 
g()21   void g(){
22     A k(i);
23   }
24 };
25 
26 
27 class D : public C {
28 public:
D(int w)29    D(int w) : C(i) {}
j()30    void j() { A k(*this); }
h()31    void h() { i=3; }
32 };
33 
f()34 void C::f() {
35    A k(*this);
36 }
37 
38 B b(3);
39 int
main()40 main() {
41  A *z = &b; // ERROR -
42 }
43