A fresh look at comparisons

Steven Schveighoffer schveiguy at yahoo.com
Wed Apr 16 06:55:51 PDT 2008


"Scott S. McCoy" <tag at cpan.org> wrote in message 
news:1208252695.9854.144.camel at thinkpad.leapfrog.local...
> Sorry, this link :-P
>
> http://codepad.org/wxG1AKBe

Yes, but then you are not overriding the base method.  This (currently) 
leaves a virtual opEquals(Object) method in the vtable which throws an 
exception:

class A
{
}

class B : A
{
   int opEquals(B b) { return 1;}
}

void main()
{
   A a = new A;
   a == new A; // ok
   a == new B; // ok
   a = new B;
   a == new A; // throws exception.
   a == new B; // throws exception.
}

-Steve 





More information about the Digitalmars-d mailing list