Article ID: 166109
Article Last Modified on 7/5/2005
/*
Compile option: None
*/
class X;
template <class T> void AFunction(X &x, T &t);
class X
{
private:
int m_n;
public:
template <class T> friend void AFunction(X &x, T &t) ;
};
template <class T> void AFunction(X &x, T &t)
{
x.m_n = t; // C2248 here.
}
int main()
{
X x;
int n;
AFunction(x, n);
return 0 ;
}
NOTE: Defining the template function before the class definition eliminates
the compiler error C2248. But the compiler does not generate any code when
you call the template function.
Keywords: kbbug kbfix kbvc600fix KB166109