opEquals footprint

xs0 xs0 at xs0.com
Wed Mar 22 07:13:06 PST 2006


Erik Rasmussen wrote:
> I've looked all around in the documentation and forum discussions, and I 
> can't find the answer to this simple, but all-important question:
> 
> ***** What should the type of the parameter to opEquals be??? *****
> 
> I can see two possibilities:
> 
> A) Object.  This would force you to check the type of the object passed 
> in as part of your equivalence check.  Could this perhaps be done at 
> compile-time with an is() expression?
> 
> B) The same type as the class.  This is fine, but I don't think 
> subclasses properly override the superclass's opEquals implementations 
> when this is the case.
> 
> Can someone settle this?  What is the proper way to implement opEquals??
> 
> Thanks,
> Erik

int opEquals(Object)

so it overrides the default implementation found in, you guessed it, 
Object :) Same goes for opCmp, I think..


xs0



More information about the Digitalmars-d-learn mailing list