Interface factory

BCS ao at pathlink.com
Tue Aug 14 10:14:21 PDT 2007


Reply to luke,

> What about casting an interface to another?
> 
> Like:
> 
> interface A{}
> interface B: A{}
> class C : B{}
> B Factory()
> {
> return new C();
> }
> auto i = cast(A)Factory();
> 
> Could this work?
> 

casting interfaces works fine, the compiler handles all the magic, however 
a function that returns the wrong type subverts this.




More information about the Digitalmars-d-learn mailing list