interface is interface

rumbu via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 17 23:00:04 PDT 2014


On Tuesday, 17 June 2014 at 19:02:34 UTC, Pavel wrote:

> class A : B, C {
>   override void test() {}
>   override void test1() {}
> }

If you swap the interfaces (class A: C, B), "a is b" will return 
false, but "a is c" will return true. Clearly, this is a bug.

>
> void main() {
> 	A a = new A();
> 	I b = cast(B)a;
> 	I c = cast(C)a;
>

If you remove the casts, will work as expected:

I b = a;
I c = a;

or even:

B b = a;
C c = a;







More information about the Digitalmars-d-learn mailing list