Sign in Join
Wiki copytemporary

subrange types/fr

Deutsch · English · Français

Plages de valeurs : La définition la détermine par elle-même.

Occupation en mémoire : Correspond au type sous-jacent.

Propriétés :

Tout autre valeur conduit à une erreur de compilation, le programme ne sera donc pas créé.

Il existe deux façons de définir les types de sous-étendue.

Variante 1, la variable est définie directement :

pascal
 Var
   tbZahl1: 10..123;
   tbBuchstabe1: 'A'..'Z';

Variante 2, on définit un sous-type en premier lieu:

pascal
 type
  TZahl2 = 10..123;
  TBuchstabe2 = 'A'..'Z';
 Var
   tbZahl2: TZahl2;
   tbBuchstabe2: TBuchstabe2;

Exemples d'affectation avec une valeur correcte :

pascal
   tbZahl1 := 10;
   tbZahl1 := 123;
   tbZahl2 := 10;
   tbZahl2 := 123;
   tbBuchstabe1 := 'F';
   tbBuchstabe2 := 'F';

Exemples d'affectation avec une valeur incorrecte :

pascal
   // la valeur est en dehors de partie du type
   tbZahl1 := 9;
   tbZahl2 := 124;
   tbBuchstabe1 := 'f';
   tbBuchstabe2 := 'f';
   // L'affectation avec des chaîne doit passer par une conversion de type
   tbZahl1 := '10';
   tbZahl1 := '123';
   tbZahl2 := '10';
   tbZahl2 := '123';

From the Free Pascal wiki, page "subrange types/fr", as it stood on 2020-02-28 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.