to 喜之狼:
//lichengbin的有点小问题,改下就ok了。
//关于类引用《Delphi面向对象编程思想》有详细介绍
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
Flag = 0;
type
{$IFDEF Flag <=1}
TMyClass = class(TList)
{$ELSEIF Flag=2}
TMyClass = class(TThreadList)
{$ELSE}
TMyClass = class(TStringList)
{$ENDIF}
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
O: TMyClass;
begin
O := TMyClass.Create;
ShowMessage(O.ClassParent.ClassName);
O.Free;
end;
end.
//to lichengbin:
//为何始终执行ELSE部分?Flag没用啊