opEquals footprint

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


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;
     }
}



More information about the Digitalmars-d-learn mailing list