in reply to OO Identity Crisis
The way Java deals with this is to make the client class provide a comparison method. So, in your example, the Node class should be able to do the following:
That's a simple and easy way to prevent duplicates without making your Tree class do more than it should.if ( $node1->isEqual( $node2 ) ) { print "The two nodes are the same!\n"; }
|
|---|