Inheriting from an interface twice

Denis Koroskin 2korden at gmail.com
Fri Oct 1 09:06:02 PDT 2010


On Fri, 01 Oct 2010 19:36:11 +0400, Trass3r <un at known.com> wrote:

>> void main()
>> {
>> 	Baz baz = new Baz();
>> 	Bar bar = baz;
>> 	
>> 	Foo foo1 = bar;
>> 	Foo foo2 = baz;
>> 	
>> 	assert(foo1 is foo2);
>> }
>>
>>
>> foo1 and foo2 have the same type and point to the same object. Yet they  
>> have different addresses. Is it a bug, or a feature?
>
> Looks fine?! Isn't foo1 == foo2 what you want?

Sadly, opEquals is only defined for Objects, not interfaces:
Error: function object.opEquals (Object lhs, Object rhs) is not callable  
using argument types (Foo,Foo)

Besides, I put `is' on purpose. With that assertion I make sure that  
references are *same*, not that they are equal.


More information about the Digitalmars-d mailing list