PRB: C2922 Error for Class Template Containing Friend Function (131066)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 2.1
This article was previously published under Q131066 SYMPTOMS
The compiler generates the following error message when the friend function
in a template class is not prototyped:
Error C2922: 'symbol' a friend function of a template
class must have been previously defined
CAUSE
Friend functions must be declared before they are used in a template class.
You cannot have a friend function defined within a class definition. This
is a Microsoft Specific requirement. Templates are not officially
standardized and, as a result, different C++ compiler vendors have
implemented them differently, so this requirement may change in future
versions of the compiler.
RESOLUTION
Declare the friend function before using it in the template definition.
STATUS
This behavior is by design.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbCompiler kbCPPonly kberrmsg kbprb KB131066 |
---|
|