Covariant problem

Zarathustra adam.chrapkowski at gmail.com
Fri Jul 25 10:37:07 PDT 2008


Koroskin Denis Wrote:

> On Thu, 24 Jul 2008 17:23:44 +0400, Zarathustra  
> <adam.chrapkowski at gmail.com> wrote:
> 
> > Sorry, for the amount of posts, but below is full and most easy example  
> > program which ilustrates problem ;)
> > ________________________________________________________
> > // class CFoo
> > //_______________________________________________
> > class CFoo{
> >   //_____________________________________________
> >   //  ::>> Attributes <<::
> >   //
> >
> >   //_____________________________________________
> >   //  << fields >>
> >  public real [] test(){ return [3.4, 4.5]; }
> > }
> >
> > // class CBar
> > //_________________________________________________
> > class CBar : CFoo{
> >     //_____________________________________________
> >   //  ::>> Attributes <<::
> >   //
> >
> >   //_____________________________________________
> >   //  << fields >>
> >   public uint [] test(){ return [9, 8, 7]; }
> > }
> >
> > void
> > main(char [][] args){
> > }
> > ________________________________________________________
> >
> 
> 
> I'm sorry, but your example is incorrect. You can't cast uint[] to real[].  
> If you need that, write a function for the task. Compiler won't do this  
> automatically. And yes, they are not covariant! :)

Of course ;) You have a right ;p
I'm blind. Now I see that I tied do something like that:
typeA function(typeX x){}
typeB function(typeX x){}
of cource compiler which function call ;p sorry my very very stiupid mistake. 


More information about the Digitalmars-d-learn mailing list