C
Cantin
Unregistered / Unconfirmed
GUEST, unregistred user!
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1}
Unit2 in 'Unit2.pas'
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
unit Unit2;
interface
type
TSam=class
public
constructor Create;
function getvalue:string;
protected
value:string;
end;
TSam1=class(TSam)
public
constructor Create;
function getvalue:integer;
end;
implementation
uses
sysUtils;
{ TSam }
constructor TSam.Create;
begin
value:='shanghai'
{编译到这里老是出错?}
end;
function TSam.getvalue: string;
begin
getvalue:=value;
end;
{ TSam1 }
constructor TSam1.Create;
begin
value:='156';
end;
function TSam1.getvalue: integer;
begin
getvalue:=strtoint(value);
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,unit2;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
samfirst:TSam;
Samsecond:TSam1;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Samfirst.create;
SamSecond.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Samfirst.Free;
SamSecond.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption :=Samfirst.getvalue;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Label1.Caption:=Inttostr(SamSecond.getvalue);
end;
end.
uses
Forms,
Unit1 in 'Unit1.pas' {Form1}
Unit2 in 'Unit2.pas'
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
unit Unit2;
interface
type
TSam=class
public
constructor Create;
function getvalue:string;
protected
value:string;
end;
TSam1=class(TSam)
public
constructor Create;
function getvalue:integer;
end;
implementation
uses
sysUtils;
{ TSam }
constructor TSam.Create;
begin
value:='shanghai'
{编译到这里老是出错?}
end;
function TSam.getvalue: string;
begin
getvalue:=value;
end;
{ TSam1 }
constructor TSam1.Create;
begin
value:='156';
end;
function TSam1.getvalue: integer;
begin
getvalue:=strtoint(value);
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,unit2;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
samfirst:TSam;
Samsecond:TSam1;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Samfirst.create;
SamSecond.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Samfirst.Free;
SamSecond.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption :=Samfirst.getvalue;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Label1.Caption:=Inttostr(SamSecond.getvalue);
end;
end.