How to use a class as key type in AAs?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun Jul 6 11:06:58 PDT 2008


"Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote in message 
news:g4r1c5$8b9$1 at digitalmars.com...
> "Moritz Warning" <moritzwarning at web.de> wrote in message 
> news:g4r043$28f$1 at digitalmars.com...
>> I've read the docs and implemented size_t getHash, int opEquals(Object o)
>> and int opCmp(Object o); but it still doesn't work.
>>
>> The following code prints out: 2 2 1
>>
>> Btw.: I tested (new Foo(1)) == (new Foo(1)) and it gives true,
>> (new Foo(1)) == (new Foo(2)) gives false.
>>
>>
>> void main()
>> {
>> class Foo
>> {
>> uint i;
>> this(uint i ) { this.i = i; }
>>
>> size_t getHash()
>> {
>> return this.i;
>> }

And, it's supposed to be "toHash", not "getHash".  This is just where 
"override" comes in handy. 




More information about the Digitalmars-d-learn mailing list