delphi 7 中,怎样把函数的返回值定义为整数数组类型?函数数组是不是像用普通数组一样使用呢?即 a[1], a[2]这样delphi 7支持对象数组吗?

解决方案 »

  1.   

    type
      Tintarr=array [0..100] of integer;function FunA():tintarr;
    其实更推荐这种操作:
    function FunB(var aintarr:Tintarr):integer;
    var 
      IntArr:TIntArr;
      
    funb(intarr);
      

  2.   

    type
      myArray=array of integer;/////////
    function getArray():myArray;
    begin
     ............
    end;
      

  3.   

    参考这一贴:http://community.csdn.net/Expert/topic/5245/5245705.xml?temp=.8390924
      

  4.   

    type
       TArr = array of integer;function abc(a:integer):Tarr;
    var
        tempArr:TArr;
    begin
        setlength(tempArr,2);
        tempArr[0] := a;
        tempArr[1] := a + 10;
        result:=tempArr;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
        a : integer;
    begin
        a := 5;
        showmessage(inttostr(   abc(a)[0]   ));  //5  //这以这样使用返回数组 
        showmessage(inttostr(   abc(a)[1]   ));  //15 //这以这样使用返回数组
    end;
      

  5.   

    delphi 7支持对象数组吗?
    -------------------------
    支持。上面所说的,都是“简单类型”的“对象”的数组。
    以下是一个按钮数组。只是演示用。var
      I : integer;
      BtnArr : array[1..5] of TButton;
    begin
      for I := Low(BtnArr) to High(BtnArr) do
          begin
          BtnArr[I] := TButton.Create(self);
          BtnArr[I].Parent := self;
          BtnArr[I].Name := 'Btn'+IntToStr(I);
          BtnArr[I].Left := 50;
          BtnArr[I].Top := I * 50;
          BtnArr[I].Width := 50;
          BtnArr[I].Height := 20;
          BtnArr[I].Show;
          end;
    end;