在Pascal中有两种类型声明:
前者只是创建方便的速记,如C中的typedef.别名是彼此兼容的,与原始类型兼容.创建的类型是故意不兼容的,并且在没有明确和不安全的情况下通过类型转换不能混合.
var
nn: NewName; nt: NewType; ot: OldType;
...
nn := ot; // should work
nt := ot; // should break with type safety violation error.
nt := NewType(ot); // Disabling type safety. Should work even if
// it has no sense semantically and types really ARE incompatible.
Run Code Online (Sandbox Code Playgroud)
根据我的理解,这些是Pascal基础知识.
现在让我们看一个特定类型和两个别名: