Re: Notation objet préfixée en Ada 20 05 (bis).

Pascal <[email protected]>
Newsgroups gmane.comp.lang.ada.france
Message-ID <[email protected]>
Bon sang mais c'est bien sûr, les agrégats étendus, nouveaux dans Ada  
2005, il me semble.
Par contre, j'obtiens l'erreur:
> 208:      return (Tour.Tour'(Constructor (N)) with X => X, Y => Y);

tourdehanoi_obj.adb:208:22: expected type "Tour" defined at line 74
tourdehanoi_obj.adb:208:22: found type "TourG" defined at line 163
J'ai écris alors:
   return ((Tour.Constructor (N)) with X => X, Y => Y);
Avec Tour qui est ici le packetage (classe) englobant le type Tour.

Merci, Pascal Pignard.
http://blady.pagesperso-orange.fr




Le 28 déc. 07 à 11:08, Jean-Pierre Rosen a écrit :

> Pascal a écrit :
>> Je vois bien le code de la première:
>>   function Constructor (N : Entier; X, Y : Entier) return TourG is
>>   T : TourG := Constructor (N);
>>   begin
>>   T.X := X; T.Y := Y;
>>   return T;
>>   end;
> Ou plus simplement:
>    function Constructor (N : Entier; X, Y : Entier) return TourG is
>    begin
>       return (Tour'(Constructor (N)) with X => X, Y => Y);
>    end;
> Ce qui appelle automatiquement le constructeur de la super-classe.
>
> Du coup, on peut définir:
>       function Constructor (N : Entier) return TourG is
>       begin
>          return Constructor (N, 0, 0);
>       end Constructor;
> Ce qui est plus logique: le constructeur simple appelle le  
> constructeur complet avec des valeurs par défaut.
> -- 
> ---------------------------------------------------------
>            J-P. Rosen ([email protected])
> Visit Adalog's web site at http://www.adalog.fr
>

_______________________________________________
Site WWW de l'association Ada-France: http://www.ada-france.org/
[email protected]
http://www.ada-france.org/mailman/listinfo/ada-france
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.