2013/08/10(Sat) 10:03:50 編集(投稿者)
さて、static の 2 引数採る operator を書かないといけないと思います。
// C++/CLI
namespace ClassLib {
public ref class TestClass
{
public:
TestClass() { }
property int a;
property int b;
property int c;
static bool operator ==(TestClass^ left, TestClass^ right)
{
if (Object::ReferenceEquals(left, right)) return true;
if (Object::ReferenceEquals(left, nullptr)) return false;
if (Object::ReferenceEquals(right, nullptr)) return false;
return (left->a == right->a && left->b == right->b && left->c == right->c);
}
};
}
// C#
static void Main(string[] args)
{
TestClass c1 = new TestClass { a = 1, b = 2, c = 3};
TestClass c2 = new TestClass { a = 1, b = 2, c = 3};
Console.WriteLine("c1 == c2? {0}", c1 == c2);
}
// 出力結果
c1 == c2? True