编译器错误 C2920
重定义:“class”:类 template 或 generic 已经声明为“type”
generic 或 template 类具有多个不等效的声明。 要解决此错误,请对不同的类型使用不同的名称,或删除类型名称的重定义。
下面的示例生成 C2920,并演示如何修复此错误:
// C2920.cpp
// compile with: /c
typedef int TC1;
template <class T>
struct TC1 {}; // C2920
struct TC2 {}; // OK - fix by using a different name
使用 generic 时,也可能发生 C2920:
// C2920b.cpp
// compile with: /clr /c
typedef int GC1;
generic <class T>
ref struct GC1 {}; // C2920
ref struct GC2 {}; // OK - fix by using a different name
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈