在线等待!!!

解决方案 »

  1.   

    XML Data banding生成的xml解析类就是很好的例子。
    同时你还能学习到xml data banding 的知识。
      

  2.   

    在向导的New里,最后一项就是xml data banding 
      

  3.   

    接口只有声明,它的实现都是在类中去实现的,那么为什么不直接用类,而为什么要先声明接口,再用类从接口那里继承然后再去实现呢,有什么好处吗?
    我现在有一个这样的例子,代码如下:
    unit Unit1;interface
    type
      IName = Interface
      ['{849EF1E1-EF57-11D5-8CB2-99DA2E405E0A}']
        Function GetName(i: integer): String;
        function GetID: string;
    end;
    implementationend.类的实现在下面这个单元里面
    unit Unit3;interface
      uses unit1;
      type TMyClass = class(TInterfacedObject, IName)
        private
        protected
          Function GetName(i: integer): String;
          function GetID: string;
        public
         constructor create;
         Destructor Destroy; override;
      end;
    implementation{ TMyClass }constructor TMyClass.create;
    begin
    end;destructor TMyClass.Destroy;
    begin
      inherited;end;function TMyClass.GetID: string;
    begin
      result := 'This is GetID test';
    end;function TMyClass.GetName(i: integer): String;
    begin
     case i of
     0:
       Result := 'This is a test of GetName(0)';
     1:
       Result :=  'This is a test of GetName(1)';
     end;end;end.我在调用时用的是下面的单元,代码如下:unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
      Dialogs, unit1, StdCtrls, Unit3, Buttons;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        FIName: IName;
        FMyClass : TMyClass;
      protected
      public
      end;
    var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    begin
      FMyClass := TMyClass.Create;
      FIName := FMYClass;
      caption := FIName.GetName(1);
    end;
    end.这样在Button1单击时便会在窗体的标题上显示返回值,可是这样的好处是什么呢,用类完全可以实现。