Export (0) Print
Expand All
Expand Minimize

Compiler Error C2701

'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
   };
}

Community Additions

ADD
Show:
© 2015 Microsoft