typeid() broken for interfaces?

Jacob Carlborg doob at me.com
Mon Dec 3 05:50:43 PST 2012


On 2012-12-03 11:20, Paulo Pinto wrote:

> When coding against interfaces, it is always a good decision not to try
> to get back the object.
>
> The main idea about using interfaces in first place is to have behavior
> independent of whatever class might implement it. If someone is trying
> to get back the implementation of a given interface, it is because the
> design is not sound in first place.

Well, one would might think that this would work:

interface I {}

class A : I {}

void main ()
{
     I i = new A;
     Object o = i;
}

But it doesn't.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list