编译器错误 C2932
“class”:type-class-id 重新定义为“identifier”的数据成员
不能将泛型或模板类用作数据成员。
此错误在 Visual Studio 2022 及更高版本中已过时。
以下示例生成 C2932:
// C2932.cpp
// compile with: /c
template<class T>
struct TC {};
struct MyStruct {
int TC<int>; // C2932
int TC; // OK
};
使用泛型时也可能发生 C2932:
// C2932b.cpp
// compile with: /clr /c
generic<class T>
ref struct GC {};
struct MyStruct {
int GC<int>; // C2932
int GC; // OK
};
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈