Delphi方法

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
  TKzx=class            //创建一个类
    Name:String;
    iYear:String;
    Procedure ShowName;       //声明一个普通方法
    class Procedure ShowStr; //声明一个类方法
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
Class Procedure TKzx.ShowStr ;   ///实现类方法
 begin
   ShowMessage('大家好');
 end;
procedure TKzx.ShowName ;       //实现普通方法
 begin
   ShowMessage(Name);
 end;
procedure ShowI(Const i;Var S:String);
 begin
   ShowMessage(s);
 end;
procedure TForm1.Button1Click(Sender: TObject);
Var
  Kzx:TKzx;
begin
  Kzx:=TKzx.Create;
  Kzx.Name:='Kzx';
  Kzx.ShowName;       //引用普通方面
  Kzx.ShowStr;        //引用类主法
  TKzx.ShowStr; //直接调用类方法
end;

initialization
 finalization
end.

 

posted @ 2013-10-30 16:07  似水@流年  阅读(406)  评论(0编辑  收藏  举报
悠悠记得当天笑 仿佛入迷 又带一点惘 种种喜悦 令人为你鼓掌 眉飞色舞千千样 你是个妙人 是个少年狂