Compiler Error C2939
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C2939.
class' : type-class-id redefined as a local data variable
You cannot use a generic or template class as a local data variable.
This error can be caused if braces are improperly matched.
The following sample generates C2939:
// C2939.cpp
template<class T>
struct TC { };
int main() {
int TC<int>; // C2939
int TC; // OK
}
C2939 can also occur when using generics:
// C2939b.cpp
// compile with: /clr
generic<class T>
ref struct GC { };
int main() {
int GC<int>; // C2939
int GC; // OK
}
Show: