opEquals footprint

Sean Kelly sean at f4.ca
Wed Mar 22 12:12:31 PST 2006


Forgot the second overload.


Sean Kelly wrote:
> xs0 wrote:
>>
>> int opEquals(Object)
>>
>> so it overrides the default implementation found in, you guessed it, 
>> Object :) Same goes for opCmp, I think..
> 
> It's probably worth also supplying overloads for the class in question, 
> as you don't want to cast if you don't have to:
> 
> class A
> {
>     int opEquals(Object o)
>     {
>         A a = cast(A) o;
> 
>         if (a is null)
>             return false;
>         else
>             return *this == a;
>     }

       int opEquals( A a )
       {
           return member1 == a.member1;
       }
> }



More information about the Digitalmars-d-learn mailing list