I have a first class that looks like:
template <typename T1, typename T2> class A
and a second class that looks like:
template <typename T1> class B
Now I would like to declare that A<T1, T2>
is always a friend of B<T1>
. So I tried:
// B.h
template <typename T1> class B
{
template <typename T2> friend class A<T1, T2>;
public:
...
}
But that does not seem to work. What should I do?
Given the you have separate files , A.h and B.h and the condition that only
A<T1,T2>
should be a friend ofB<T1>
, then :