テンプレートを含める場合、
クラスとそれらのフレンドとの間には 4 種類の関係があります。
次の例は、これらの関係を示しています。
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(); };
The friend function declaration "f" will cause an error when the enclosing template class is instantiated with arguments that declare a friend function that does not match an existing definition. The function declares only one function because it is not a template but the function type depends on one or more template parameters.
これらの関係は、フレンド・クラスにも適用します。
関連参照