Friends and templates (C++ only)

There are four kinds of relationships between classes and their friends when templates are involved:

The following example demonstrates these relationships:

class B{
   template<class V> friend int j();
}

template<class S> g();

template<class T> class A {
   friend int e();
   friend int f(T);
   friend int g<T>();
   template<class U> friend int h();
};

These relationships also apply to friend classes.

Related information