Originale-mail to me for new edition

 

Array types and assignments

 

Arrays are assignment-compatible only if they are of the same type. Because Pascal uses name-equivalence for types, the following code will not compile.

var

  Int1: array[1..10] of Integer;

  Int2: array[1..10] of Integer;

  ...

Int1 := Int2;

To make the assignment work, declare the variables as

var Int1, Int2: array[1..10] of Integer;

or

type IntArray = array[1..10] of Integer;

var

  Int1: IntArray;

  Int2: IntArray;

 

Topic groups

 

See also

Arrays: Overview

Type compatibility and identity: Overview

 

 

译文

 

数组类型和赋值

 

数组之间是赋值兼容的当且仅当它们属于相同的类型。因为Because Pascal对类型采用名称相等(name-equivalence)的规则判定类型是否相同,所以下面的代码不能成功编译:

var

  Int1: array[1..10] of Integer;

  Int2: array[1..10] of Integer;

  ...

Int1 := Int2;

要实现此处的赋值操作,可以如下声明变量

var Int1, Int2: array[1..10] of Integer;

或者

type IntArray = array[1..10] of Integer;

var

  Int1: IntArray;

  Int2: IntArray;

 

主题组

 

相关主题

数组:概述

类型兼容和等同:概述