Getting most derived type of object that implements interface
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 25 05:29:33 PDT 2016
On 7/25/16 5:54 AM, Kagamin wrote:
> Cast it to Object:
> FooInterface a = new BarImplementsInterface();
> FooBaseClass b = new BarDerivedClass();
> Object o = cast(Object)a;
> writefln("a class: %s", a.classinfo.name);
> writefln("b class: %s", b.classinfo.name);
> writefln("o class: %s", o.classinfo.name);
Yes, for the unrelated reason that COM objects may not be D objects,
interfaces that can only possibly be D Objects don't implicitly cast to
Object.
-Steve
More information about the Digitalmars-d-learn
mailing list