Article ID: 815646 - View products that this article applies to.
This article describes the C2061 compiler error message that is received in different versions of Microsoft Visual C++.
In Microsoft Visual C++ 6.0 and in Microsoft Visual C++ .NET, you receive the following error message:
In Visual C++ .NET 2002, you may also receive the following error message:
Compiler Error C2061 syntax error : identifier 'identifier'
In Visual C++ .NET 2003, you may also receive the following error message:
error C2947: expecting '>' to terminate template-parameter-list,found '>'
warning C4346: 'T::type' : dependent name is not a type prefix with 'typename' to indicate a type.
Visual C++ 6.0In Visual C++ 6.0, a C2061 compiler error occurs when you enclose an initializer in parentheses. To resolve this behavior, enclose the declarator in parentheses or define the declarator as typedef. This code specifies two fixes:
Visual C++ .NET 2002However, the code in the "Visual C++ 6.0" section does not cause an error in Visual C++ .NET 2002. In Visual C++ .NET 2002, the following code causes the C2061 error when it is compiled with the /Za compiler switch. You may also receive a C2947 error with the C2061 error.
Visual C++ .NET 2003In Visual C++ .NET 2003, the C2061 error occurs when the compiler detects an expression as a class template argument. You receive the C2061 error even when the /Za compiler switch is not used. In addition to the C2061 error, you may also receive a C2947 error and a C4346 error.
You may modify the code in Visual C++ .NET 2003 by using the typename keyword as follows:
When you use template parameter as a type, you must use the typename keyword. According to ANSI C++ standards, a qualified name that refers to a type type specifier and that depends on a template parameter must be prefixed by the typename keyword.