B
Blue_Fire
Unregistered / Unconfirmed
GUEST, unregistred user!
请教各位大侠:两段代码如此相似,
1> 为什么unit1能够执行,而unit2不能够执行。
2> 为什么在退出unit1时出现了内存访问错误。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
end;
TTemp=class
private
data1:string;
data2:string;
data3:string;
end;
TMold=class(TTemp)
procedure setdata(v_data1 :string; V_data2 :string; V_data3 :string );
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TMold.setdata(V_data1 :string;V_data2 :string; V_data3 :string);
begin
data1:=V_data1;
data2:=V_data2;
data3:=V_data3;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
mold:TMold;
begin
mold.create;
mold.setdata(edit1.text, edit2.text, edit3.text);
showmessage(mold.data1+ mold.data2+ mold.data3);
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
procedure Button1Click(Sender: TObject);
end;
TTemp=class
private
data1:string;
data2:string;
data3:string;
data4:string;
end;
TMold=class(TTemp)
procedure setdata(v_data1 :string; V_data2 :string; V_data3 :string; V_data4:string );
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TMold.setdata(V_data1 :string;V_data2 :string; V_data3 :string; V_data4:string );
begin
data1:=V_data1;
data2:=V_data2;
data3:=V_data3;
data4:=V_data4;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
mold:TMold;
begin
mold.create;
mold.setdata(edit1.text, edit2.text, edit3.text, edit3.text );
showmessage(mold.data1+ mold.data2+ mold.data3+ mold.data4 );
end;
end.
还有一点小弟不明白,在delphi里面如何采用文件型而不是C/S型数据库?
请赐教,不深感激!
1> 为什么unit1能够执行,而unit2不能够执行。
2> 为什么在退出unit1时出现了内存访问错误。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
end;
TTemp=class
private
data1:string;
data2:string;
data3:string;
end;
TMold=class(TTemp)
procedure setdata(v_data1 :string; V_data2 :string; V_data3 :string );
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TMold.setdata(V_data1 :string;V_data2 :string; V_data3 :string);
begin
data1:=V_data1;
data2:=V_data2;
data3:=V_data3;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
mold:TMold;
begin
mold.create;
mold.setdata(edit1.text, edit2.text, edit3.text);
showmessage(mold.data1+ mold.data2+ mold.data3);
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
procedure Button1Click(Sender: TObject);
end;
TTemp=class
private
data1:string;
data2:string;
data3:string;
data4:string;
end;
TMold=class(TTemp)
procedure setdata(v_data1 :string; V_data2 :string; V_data3 :string; V_data4:string );
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TMold.setdata(V_data1 :string;V_data2 :string; V_data3 :string; V_data4:string );
begin
data1:=V_data1;
data2:=V_data2;
data3:=V_data3;
data4:=V_data4;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
mold:TMold;
begin
mold.create;
mold.setdata(edit1.text, edit2.text, edit3.text, edit3.text );
showmessage(mold.data1+ mold.data2+ mold.data3+ mold.data4 );
end;
end.
还有一点小弟不明白,在delphi里面如何采用文件型而不是C/S型数据库?
请赐教,不深感激!