“class”:type-class-id 重新定义为全局函数
不能将泛型或模板类用作全局函数。
此错误在 Visual Studio 2022 及更高版本中已过时。
如果大括号匹配不正确,则可能导致此错误。
以下示例生成 C2935:
// C2935.cpp
// compile with: /c
template<class T>
struct TC {};
void TC<int>() {} // C2935
// OK
struct TC2 {};
void TC2() {}
使用泛型时也可能发生 C2935:
// C2935b.cpp
// compile with: /clr /c
generic<class T>
ref struct GC { };
void GC<int>() {} // C2935
void GC() {} // OK