opEquals for multiple types

Wouter Verhelst wouter at grep.be
Sun Jul 8 09:56:25 PDT 2012


Hi,

I'm trying to implement opEquals. I had originally done something like

class foo : bar {
      bool opEquals(bar e) {
           ... code here ...
      }
      bool opEquals(foo e) {
           ... somewhat more specialized code here ...
      }
}

(where bar is an interface)

but that gave me a message about how hiding Object.opEquals is
deprecated.

My next attempt was to add a

      bool opEquals(Object o)

which would then decide which opEquals function to call based on what
typeid() on the Object returns. But since I want to have a version
involving an interface, that's not going to fly.

What's the best way forward?

-- 
The volume of a pizza of thickness a and radius z can be described by
the following formula:

pi zz a


More information about the Digitalmars-d-learn mailing list