DELPHI二维数组设置长度的时候出现了难以理解的问题!急求高人指教!

在定义数据结构的UNIT里定义了这样一个TYPE:b_arr:arrayofarrayofdouble;在另一个UNIT里使用,定义b:b_arr;在为b初始化长度时,发... 在定义数据结构的UNIT里定义了这样一个TYPE:b_arr:array of array of double;
在另一个UNIT里使用,定义b:b_arr;
在为b初始化长度时,发现b里最多只能容纳730个元素??一超出这个范围就报溢出错误,请教这是怎么回事???

例如:setlength(b,27,27);或者setlength(b,25,29),都没有问题,setlength(28,28);或者setlength(b,29,26);就报错了,'Access violation at address 00401059 in module 'test.exe'. Write of address 0000001D'。没辙了,哪位大人给个办法?
展开
 我来答
onysue
2010-10-25 · 超过24用户采纳过TA的回答
知道答主
回答量:56
采纳率:0%
帮助的人:68.2万
展开全部

unit Unit1;

interface

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, StdCtrls, Buttons;

type

  b_arr=array of array of double;

  TForm1 = class(TForm)

    BitBtn1: TBitBtn;

    procedure BitBtn1Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);

var

  I,Imax:Integer;

  A:b_arr;

begin

    Imax:=100;

    SetLength(A, Imax) ;

    for i := Low(A) to High(A) do

    begin

      setlength(A[i],Imax);

    end;

    A[99][90]:=0.55;

end;

end. 

{

//可以封装实现多维 现在设置本身就是一个A[100][100]

//10000元素数组

//理论数据最大极限应该 Maxinteger

Unit

System

Category

string handling routines

Delphi syntax:

procedure SetLength(var S; NewLength: Integer);

Description

S is a Delphi string or dynamic-array variable.

NewLength is the new number of characters or elements in S.

For a short-string variable, SetLength simply sets the length-indicator character (the character at S[0]) to the given value. In this case, NewLength must be a value between 0 and 255.

For a long-string or dynamic-array variable, SetLength reallocates the string or array referenced by S to the given length. Existing characters in the string or elements in the array are preserved, but the content of newly allocated space is undefined. The one exception is when increasing the length of a dynamic array in which the elements are types that must be initialized (strings, Variants, Variant arrays, or records that contain such types). When S is a dynamic array of types that must be initialized, newly allocated space is set to 0 or nil.

For dynamic arrays, SetLength may take more than one length parameter (up to the number of array dimensions). Each parameter specifies the number of elements along a particular dimension.

Following a call to SetLength, S is guaranteed to reference a unique string or array梩hat is, a string or array with a reference count of one. If there is not enough memory available to reallocate the variable, SetLength raises an EOutOfMemory exception. 

//请检查是不是delphi没有更新补丁 我测试用你方法也可以

已赞过 已踩过<
你对这个回答的评价是?
评论 收起
googleyeyou
2010-10-19 · TA获得超过186个赞
知道小有建树答主
回答量:269
采纳率:100%
帮助的人:160万
展开全部
二维需要循环设
你这么设,只是设的某一维的数组个数
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式