tf,tb是对象名,而非对象变量名,而且构造函数前缀为Constructor而非Procedure或Function,修改如下
表时间:2001-5-23 12:17:00
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
//procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
tf=class
constructor create;
end;
tb=class(tf)
constructor create;
end; var
Form1: TForm1;implementation
{$R *.DFM}constructor tf.create;
begin
showmessage('father')
end;constructor tb.create;
begin
showmessage('boy')
end;procedure TForm1.Button1Click(Sender: TObject);
var t : tf;
begin
t := tf.create;
t.free;
end;procedure TForm1.Button2Click(Sender: TObject);
var t: tb;
begin
t := tb.create;
t.free;
end;end.
表时间:2001-5-23 12:17:00
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
//procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
tf=class
constructor create;
end;
tb=class(tf)
constructor create;
end; var
Form1: TForm1;implementation
{$R *.DFM}constructor tf.create;
begin
showmessage('father')
end;constructor tb.create;
begin
showmessage('boy')
end;procedure TForm1.Button1Click(Sender: TObject);
var t : tf;
begin
t := tf.create;
t.free;
end;procedure TForm1.Button2Click(Sender: TObject);
var t: tb;
begin
t := tb.create;
t.free;
end;end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货