August 20, 2012

Alıntı:

>

http://dlang.org/interface.html

> interface D {
>     int foo();
> }
>
> class A : D {
>     int foo() { return 1; }
> }
>
> class B : A, D {
>     int foo() { return 2; }
> }
>
> ...
>
> B b = new B();
> b.foo();        // returns 2
> D d = cast(D) b;
> d.foo();        // returns 2
> A a = cast(A) b;
> D d2 = cast(D) a;
> d2.foo();       // returns 2, even though it is A's D, not B's D
> ```

>

Olaya bakın...:)

-- 
[ Bu gönderi, <http://ddili.org/forum>'dan dönüştürülmüştür. ]
August 20, 2012

Orada tek 'new' var ve o 'new' B türünde bir nesne üretiyor. Hangi arayüz ile erişilirse erişilsin foo()'nun 2 döndürmesi normal çünkü nesne bir B.

Ali

--
[ Bu gönderi, http://ddili.org/forum'dan dönüştürülmüştür. ]