Class info on interfaces

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 26 11:53:16 PDT 2015


I noticed the calling "classinfo" on an interface returns the class info 
of the static type and not the dynamic type. Is that intentional? 
Perhaps because of COM and C++ interfaces?

module main;

import std.stdio;

interface Foo {}
class Bar : Foo {}

void main()
{
     Foo f = new Bar;
     writeln(f.classinfo);
}

The above program will print the static type "main.Foo" instead of the 
dynamic type "main.Bar".

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list