www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 958] New: opEquals and opCmp doesn't take Object anymore

reply d-bugmail puremagic.com writes:

           Summary: opEquals and opCmp doesn't take Object anymore
           Product: D
           Version: 1.005
          Platform: PC
               URL: http://www.digitalmars.com/d/operatoroverloading.html
        OS/Version: Windows
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: torhu yahoo.com

class C {
        bool opCmp(Object) { return true; }

void main()
        C c1 = new C;
        C c2 = new C;

        if (c1 == c2) { }

This produces the error:
opcmp.d(2): function opcmp.C.opCmp of type bool(Object) overrides but is not
ariant with object.Object.opCmp of type int(Object o)

The same thing applies to opEquals.  So the section called "Overloading == and
!=" is doesn't match the compiler's behavior anymore.

Feb 13 2007
parent d-bugmail puremagic.com writes:

torhu yahoo.com changed:

           What    |Removed                     |Added
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

------- Comment #1 from torhu yahoo.com  2007-02-13 08:56 -------
Nevermind.  I used 'bool opCmp(Object)' instead of 'int opCmp(Object)'.  How

Feb 13 2007