This documentation is archived and is not being maintained.

Compiler Error C3298

Error Message

'constraint_1' : cannot use 'constraint_2' as a constraint because 'constraint_2' has the ref constraint and 'constraint_1' has the value constraint

You cannot specify mutually exclusive characteristics for a constraint. For example, a generic type parameter cannot be constrained to both a value type and a reference type.

For more information, see Constraints.


The following sample generates C3298.

// C3298.cpp
// compile with: /clr /c 
generic<class T, class U>
where T : ref class
where U : T, value class   // C3298
public ref struct R {};