template<class T> class BE{
template<class T> friend class BT;
};
Is not allowed because template parameters cannot shadow each other. Nested templates must have different template parameter names.
template<typename T>
struct foo {
template<typename U>
friend class bar;
};
This means that bar
is a friend of foo
regardless of bar
‘s template arguments. bar<char>
, bar<int>
, bar<float>
, and any other bar
would be friends of foo<char>
.
template<typename T>
struct foo {
friend class bar<T>;
};
This means that bar
is a friend of foo
when bar
‘s template argument matches foo
‘s. Only bar<char>
would be a friend of foo<char>
.
In your case, friend class bar<T>;
should be sufficient.