Why does Object.opEquals return int

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Mon Nov 13 11:32:35 PST 2006


Bill Baxter wrote:
>                 Also I you're free to make your own classes return bool 
> from opCmp, it's just Object opCmp that returns int.

Maybe you forgot that a "bool opCmp" doesn't override Object.opCmp :(.
This means that any object ever compared as [1], well, an Object will 
still need to define "int opCmp" or run into a potentially hard-to-spot bug.


[1]: or /to/, if your "bool opCmp"'s parameter isn't an Object but 
something else (such as a more derived type, typically that of your class).



More information about the Digitalmars-d mailing list