A
Archerfl
Unregistered / Unconfirmed
GUEST, unregistred user!
我的代码:
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;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
TMyClass = class
procedure Test;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
k: TMyClass;
begin
// k := TMyClass.Create;
k.Test;
end;
{ TMyClass }
procedure TMyClass.Test;
begin
ShowMessage('不创建实例,仍可调用!');
end;
end.
如上所示,调试通过,运行正常,加注释那句用不用无所谓。这是为什么呀?
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;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
TMyClass = class
procedure Test;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
k: TMyClass;
begin
// k := TMyClass.Create;
k.Test;
end;
{ TMyClass }
procedure TMyClass.Test;
begin
ShowMessage('不创建实例,仍可调用!');
end;
end.
如上所示,调试通过,运行正常,加注释那句用不用无所谓。这是为什么呀?