編譯器錯誤 C2937
'class' :type-class-id 重新定義為全域 typedef
您無法使用泛型或樣本類別作為全域 typedef
。
在 Visual Studio 2022 和更新版本中,此錯誤已經過時。
下列範例會產生 C2937:
// C2937.cpp
// compile with: /c
template<class T>
struct TC { };
typedef int TC<int>; // C2937
typedef TC<int> c; // OK
使用泛型時,也會發生 C2937:
// C2937b.cpp
// compile with: /clr
generic<class T>
ref struct GC { };
typedef int GC<int>; // C2937
typedef GC<int> xx; // OK