定义了
procedure pro(var myArr:array of Integer);
begin
  setlength(myArr,12);
end;setlength这一句出错了,说是类型不匹配,不知道如何解决

解决方案 »

  1.   

    type TArrInt=array of Integer;
    procedure pro(var myArr:TArrInt); 
    begin 
      setlength(myArr,12); 
    end; 行不行?
      

  2.   

    Within the body of a routine, open array parameters are governed by the following rules.They are always zero-based. The first element is 0, the second element is 1, and so forth. The standard Low and High functions return 0 and Length1, respectively. The SizeOf function returns the size of the actual array passed to the routine. 
    They can be accessed by element only. Assignments to an entire open array parameter are not allowed. 
    They can be passed to other procedures and functions only as open array parameters or untyped var parameters. They cannot be passed to [color=#FF0000]SetLength.[/color] 
    Instead of an array, you can pass a variable of the open array parameter's base type. It will be treated as an array of length 1.