Why does Object.opEquals return int
Bill Baxter
wbaxter at gmail.com
Mon Nov 13 12:44:34 PST 2006
Frits van Bommel wrote:
> 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.
>
>
> [You mean opEquals, of course]
>
> Maybe you forgot that a "bool opEquals" doesn't override Object.opEquals
> :( .
> This means that any object ever compared as [1], well, an Object will
> still need to define "int opEquals" or run into a potentially
> hard-to-spot bug.
>
>
> [1]: or /to/, if your "bool opEquals"'s parameter isn't an Object but
> something else (such as a more derived type, typically that of your class).
Yes, I thought that it was uncommon for derived classes to be concerned
with comparing against base Objects by value.
--bb
More information about the Digitalmars-d
mailing list