opEquals for same type

deed none at none.none
Tue Dec 4 16:12:45 PST 2012


interface I
{
     // ...
     bool opEquals(I i);
}

class C : I
{
     // ...
     bool opEquals(I i)
     {
         return true;
     }
}

void main()
{
     I i1 = new C;
     I i2 = new C;
     assert(i1 == i2); // Assertion failure
     assert(i1 != i2); // Passes, although it's the opposite of 
what I want...
}

What's missing?


More information about the Digitalmars-d-learn mailing list