OSDN Git Service

add missing tests, put in various test adjustments from devo
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.law / visibility1.C
1 // Build don't link: 
2 // GROUPS passed visibility
3 #include <iostream.h>
4
5
6
7 class base {
8 //==========
9
10     void base_priv(char * n)            
11         { cout << "base_priv called from: " << n << "\n";  };
12
13 protected:
14
15     void base_prot(char * n) 
16         { cout << "base_prot called from: " << n << "\n"; };
17
18 public:
19
20     void base_publ(char * n) 
21         { cout << "base_publ called from: " << n << "\n"; };
22
23     void test(char * n) { base_publ(n); base_prot(n); base_priv(n); }
24
25 }; // class base
26  
27
28
29 class derived : private base {  // Make this public, 
30 //============================  // and we don't get an error
31
32 friend void derived_friend();
33
34 public :
35
36     void test(char * n) { base_publ(n); base_prot(n);}
37
38 }; // class derived
39
40
41
42 void
43 derived_friend()
44 //--------------
45 {
46     derived pd;
47
48     pd.base_publ("friend of derived class");    // Compiler error here
49     pd.base_prot("friend of derived class");
50 }
51
52
53
54 main(int argc, char *argv[])
55 //==========================
56 {
57     base b;
58     b.base_publ("base class object");
59     b.test("member of base class object");
60     cout << "\n";
61
62     derived pd;
63     pd.test("member of derived class object");
64     derived_friend();
65     cout << "\n";
66
67 } /* main */
68