summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.law/visibility2.C
blob: 539169639c3c470a0124281cc26e949be000fa1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// { dg-do assemble  }
// GROUPS passed visibility
#include <iostream>



class base {
//==========

    void base_priv(const char * n) 		
	{ std::cout << "base_priv called from: " << n << "\n";  }

protected:

    void base_prot(const char * n) 
	{ std::cout << "base_prot called from: " << n << "\n"; }

public:

    void base_publ(const char * n) 
	{ std::cout << "base_publ called from: " << n << "\n"; }

    void test(const char * n) { base_publ(n); base_prot(n); base_priv(n); }

}; // class base
 


class derived : public base {	// Make this public, 
//============================	// and we don't get an error

friend void derived_friend();

public :

    void test(const char * n) { base_publ(n); base_prot(n);}

}; // class derived



void
derived_friend()
//--------------
{
    derived pd;

    pd.base_publ("friend of derived class");	// Compiler error here
    pd.base_prot("friend of derived class");
}



int main(int argc, char *argv[])
//==========================
{
    base b;
    b.base_publ("base class object");
    b.test("member of base class object");
    std::cout << "\n";

    derived pd;
    pd.test("member of derived class object");
    derived_friend();
    std::cout << "\n";

} /* main */