请管理员介绍高手,想向他们请教问题 [email protected]
我想在自己的类中使用动态数组或动态内存
type 
  myclass=class
   public
    a: array of integer;
    b: pinteger;
  end;
....
var
  mc: myclass;
begin
  setlength(a,100);
  Getmem(b,100);
end;
  出现问题,不知应该怎样定义。另外,若b指针的第10个整数如何取得? 请高手指教 谢谢

解决方案 »

  1.   

    1 用a:Pinteger;
    2 用b:=a[10];
      

  2.   

    你好,我定义了一个类,在类中使用了动态数组,
      在程序中declare这个类,并setlength,但在退出程序时有问题
    另外您的
      1 用a:Pinteger;
      2 用b:=a[10];
    不明白,pchar可以,但pinteger不可以
    多谢指教,请再交流
      

  3.   

    对象还没创建呢……
    先得mc=myclaas.create吧……
      

  4.   

    to lldwolf:
       仍然有问题,加create也不行,在getmem时就出问题了
      

  5.   

    取b的第10个
    i:=Integer(Pinteger(Integer(b) + 9));
      

  6.   

    to firetoucher:
      you are right,but the main problem is """getmem or setlength """var
      mc: myclass;//??????????是否不能声明
    begin
      mc.create;
      setlength(a,100);//出问题的地方在此行
      Getmem(b,100);
    end;
      

  7.   

    问题未解决,下周再见
    高手解答请发送到[email protected]
      

  8.   

    var
      mc: myclass;
    begin
      mc := MyClass.Create;
      with mc do
      try
        Setlength(a,100);
        Getmem(b, 100);
      finally
        Free;
      end;
    end;