Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə110/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   106   107   108   109   110   111   112   113   ...   294
DelphiLanguageGuide

Type Compatibility and Identity
To understand which operations can be performed on which expressions, we need to distinguish several kinds of
compatibility among types and values. These include:
Type identity
Type compatibility
Assignment compatibility
Type Identity
When one type identifier is declared using another type identifier, without qualification, they denote the same type.
Thus, given the declarations
type
  T1 = Integer;
  T2 = T1;
  T3 = Integer;
  T4 = T2;
T1

T2

T3

T4
, and Integer all denote the same type. To create distinct types, repeat the word type in the declaration.
For example,
type TMyInteger = type Integer;
creates a new type called 
TMyInteger
 which is not identical to Integer.
Language constructions that function as type names denote a different type each time they occur. Thus the
declarations
type
  TS1 = set of Char;
  TS2 = set of Char;
create two distinct types, 
TS1
 and 
TS2
. Similarly, the variable declarations
var
  S1: string[10];
  S2: string[10];
create two variables of distinct types. To create variables of the same type, use
var S1, S2: string[10];
or
type MyString = string[10];
var
97


    S1: MyString;
    S2: MyString;

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   106   107   108   109   110   111   112   113   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin