how to use “where” keyword to add constraints to a generic class in CLI/C++? I’ve been searching for a while – but even msdn has only C# documentation!
So the first part of the question is: where to put “where” and what can be written next to it when defining generic classes?
generic <class T> ref class Stack
{
//........
}
Second part of the question is: what does where T:IComparable mean in the function definition below?
generic <typename T> where T:IComparable
T Function(array <T>^ x)
{
T max(x[0]);
for(int i = 1; i < x->Length; i++)
if(max-> CompareTo(x[i]) < 0)
max = x[i];
return max;
}
wheregoes betweengeneric <class T>andref class Stack.From the C++/CLI documentation: