1 class X 2 { 3 friend class A; 4 }; 5 6 7 template <typename T1, typename T2> 8 class B 9 { 10 }; 11 12 template <class T> 13 struct C 14 { 15 }; 16 17 class D 18 { 19 B<D, class A> x; 20 friend struct C<A>; 21 }; 22