How to Compare 2 objects of the same class

Mark via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 3 13:02:13 PDT 2017


On Saturday, 3 June 2017 at 19:57:47 UTC, Mark wrote:
> Hello again.
>
> I'm designing a template version of a BST.
>
> Because of this, I want to be able to compare if two objects of 
> the same class type are references to the same anonymous class 
> on the heap somewhere.
>
> Example:

Not sure what happened there.

Anyways, example:

auto A = new Box();
auto B = new Box();

if(A.opEquals(B)) {}

gives the error
test.o:(.data.rel.ro+0x18): undefined reference to 
`_D5Stack12__ModuleInfoZ'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1

if(Object.opEquals(A,B) gives

test.d(10): Error: function object.Object.opEquals (Object o) is 
not callable using argument types (Box, Box)


How do I got about comparing two objects then??
Thanks.



More information about the Digitalmars-d-learn mailing list