Covariant problem

Koroskin Denis 2korden at gmail.com
Thu Jul 24 07:16:31 PDT 2008


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! :)


More information about the Digitalmars-d-learn mailing list