This documentation is archived and is not being maintained.

Compiler Error C2701

Error Message

'function' : a function template cannot be a friend of a local class

A local class cannot have a template function as a friend function.

The following sample generates C2701:

// C2701.cpp
// compile with: /c
template<typename T>   // OK
void f1(const T &);

void MyFunction() {
   class MyClass {
      template<typename T> friend void f2(const T &);   // C2701
   };
}
Show: