比如我声明了:
type
  xmltree = class
    public
      str:string;
  end;
  po=^xmltree;我想动态使用这个类比如xmlpoint:po;
new(xmlpoint);
xmlpoint^.str:='sjsjs';可是好象会出错这是为什么该怎么样实现他呢?请各位帮忙!

解决方案 »

  1.   

    这不叫动态使用类,这叫动态创建对象,使用类应该用TClass,也就是类的类~~~Object Pascal中创建对象需要显式调用构造函数xmlpoint := xmltree.Create;
      

  2.   

    procedure TForm1.Button4Click(Sender: TObject);
    var
      Myxmltree: xmltree;
    begin
      Myxmltree := xmltree.Create;
      Myxmltree.str := '1234';
      ShowMessage(Myxmltree.str);
      Myxmltree.Free;
    end;
      

  3.   

    xmlpoint:po;
    new(xmlpoint);
    xmlpoint^:=xmltree.Create;//创建事例
    xmlpoint^.str:='sjsjs';
      

  4.   

    rockswj(石头) (你说的我试了好象不行哦!
    ehom(?!) 你能说的更详细一点吗?谢谢了哦 !
      

  5.   

    我试了怎么可以:
    type
      xmltree = class
        public
          str:string;
      end;
      po=^xmltree;
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    var
      Form1: TForm1;
    implementation
    {$R *.DFM}
    procedure TForm1.Button1Click(Sender: TObject);
    var  xmlpoint:po;
    begin
      new(xmlpoint);
      xmlpoint^:=xmltree.Create;
      xmlpoint^.str:='sjsjs';
      ShowMessage(xmlpoint^.str);
      xmlpoint^.Free;
      dispose(xmlpoint);
    end;
      

  6.   

    xmlpoint^?????这是指针的指针??????????????