T
tonvandenheuvel
Hi all,
the following code does not compile in gcc 4.0.2:
3 class Outer
4 {
5 class B;
6
7 template<typename T>
8 class A
9 {
10 friend class Outer::B;
11
12 public:
13 A(T t): a(t) { };
14 A() { };
15 protected:
16 T a;
17 };
18
19 class B : public A<int>
20 {
21 public:
22 B(A<int> & a)
23 {
24 b = a.a;
25 }
26
27 int b;
28 };
29 };
The error I get is:
friend.cpp: In constructor 'Outer::B::B(Outer::A<int>&)':
friend.cpp:16: error: 'int Outer::A<int>::a' is protected
friend.cpp:24: error: within this context
Note that when the Outer class is stripped, everything compiles just
fine. What is the problem here?
the following code does not compile in gcc 4.0.2:
3 class Outer
4 {
5 class B;
6
7 template<typename T>
8 class A
9 {
10 friend class Outer::B;
11
12 public:
13 A(T t): a(t) { };
14 A() { };
15 protected:
16 T a;
17 };
18
19 class B : public A<int>
20 {
21 public:
22 B(A<int> & a)
23 {
24 b = a.a;
25 }
26
27 int b;
28 };
29 };
The error I get is:
friend.cpp: In constructor 'Outer::B::B(Outer::A<int>&)':
friend.cpp:16: error: 'int Outer::A<int>::a' is protected
friend.cpp:24: error: within this context
Note that when the Outer class is stripped, everything compiles just
fine. What is the problem here?