How to get the implementer of an interface?
Denis Koroskin
2korden at gmail.com
Thu Jan 22 00:30:07 PST 2009
On Thu, 22 Jan 2009 11:17:20 +0300, Qian Xu <quian.xu at stud.tu-ilmenau.de> wrote:
> Hello All,
>
> how to get the implementer of an interface?
>
> Here is an example:
> -------------------------------------------------------------
> interface intf_1 {}
> class c_1 : intf_1 {}
> class c_2 : c_1 {}
>
> c_1 aaa = new c_1;
> c_2 bbb = new c_2;
> auto list = [cast(intf_1)(bbb), cast(intf_1)(aaa)];
> foreach (intf_1 i; list)
> {
> print_intf_implementor(i);
> // bbb should return "c_2"
> // aaa should return "c_1"
> }
> -------------------------------------------------------------
>
>
> --Qian
Try the following:
writefln(cast(Object)i);
More information about the Digitalmars-d-learn
mailing list