#include "stdafx.h"
using namespace System;
generic where K : IComparable
ref class KVClass{
public:
property K Key;
property V Value;
KVClass(K key, V value);
V isGreater(KVClass ^in);
};
generic
KVClass::KVClass(K key, V value)
{
Key = key;
Value = value;
}
genericwhere K : IComparable
V KVClass::isGreater(KVClass ^in){
if (Key->CompareTo(in->Key) > 0)
return Value;
else
return in->Value;
}
void main(){
KVClass ^a = gcnew KVClass(5, "Five");
KVClass ^b = gcnew KVClass(6, "Six");
Console::WriteLine(a->isGreater(b));
KVClass ^t = gcnew KVClass("A", 1);
KVClass ^c = gcnew KVClass("B", 2);
Console::WriteLine(t->isGreater(c));
}