分享方式:


編譯器警告 (層級 1) C4688

'constraint': 條件約束清單含有組件私用類型 'type',將無法由組件外部存取

條件約束清單具有組件的私用類型,這表示在組件外部存取類型時將無法使用它。 如需詳細資訊,請參閱泛型

範例

下列範例會產生 C4688。

// C4688.cpp
// compile with: /clr /c /W1
ref struct A {};   // private type
public ref struct B {};

// Delete the following 3 lines to resolve.
generic <class T>
where T : A   // C4688
public ref struct M {};

generic <class T>
where T : B
public ref struct N {};