memo1.Lines.Add(''Create newspaper object successed!'');
memo1.Lines.Add(''read : '' + Info + '' return code : '' + inttostr(i));
finally
FreeMem(Info);
NewspaperObj.Free;
end;
end;
end;
// interface方法示例
procedure TfmMain.btnUseInterfaceClick(Sender: TObject);
var
CircleObj: ICircle;
Info: pchar;
i: integer;
begin
CircleObj := GetCircle;
if CircleObj = nil then
memo1.Lines.Add(''Create circle object failed!'')
else
begin
try
GetMem(Info, 255);
i := CircleObj.Scroll(Info);
memo1.Lines.Add(''Create circle object successed!'');
memo1.Lines.Add(''scroll : '' + Info + '' return code : '' + inttostr(i));
finally
FreeMem(Info);
CircleObj := nil;
end;
end;
end;
// class reference方法示例
procedure TfmMain.btnUseReferenceClick(Sender: TObject);
var
BallObj : TIBall;
Info: pchar;
i: integer;
begin
BallObj := GetBall.Create;
if BallObj = nil then
memo1.Lines.Add(''Create ball object failed!'')
else
begin
try
GetMem(Info, 255);
i := BallObj.Play(Info);
memo1.Lines.Add(''Create ball object successed!'');
memo1.Lines.Add(''play : '' + Info + '' return code : '' + inttostr(i));
finally
FreeMem(Info);
BallObj.Free;
end;
end;
end;
// .inc文件方法示例
procedure TfmMain.btnUseIncClick(Sender: TObject);
var
CarObj : TCar;
Info: pchar;
i: integer;
begin
CarObj := GetCar.Create;
if CarObj = nil then
memo1.Lines.Add(''Create car object failed!'')
else
begin
try
GetMem(Info, 255);
i := CarObj.Run(Info);
memo1.Lines.Add(''Create car object successed!'');
memo1.Lines.Add(''car : '' + Info + '' return code : '' + inttostr(i));
finally
FreeMem(Info);
CarObj.Free;
end;
end;
end;
end.
UnitPublic.pas源代码:
unit UnitPublic;
interface
type
// ----- virtual, abstract的类定义 -----
TPaper = class(TObject);
TNewspaper = class(TPaper)
public
function Read(info : pchar) : integer; virtual; abstract;
end;
implementation
end.
UnitIDest.pas源代码:
unit UnitIDest;
interface
type
ICircle = interface
[''{A971