举个类工厂的例子应该能够解决你的问题
{********************************************************************
类 名:TFactory
********************************************************************}
TFactory=class
public
class function Getflag(AccType:TAccType):Tabc;
end;
TType=(sfde,sfde1,sfde2,sfde3,sfde4,
sfde5,sfde6,);
Tsfde1 = class (Tabc)
private
..
public
..
Tsfde2 = class (Tabc)
private
..
public
Tsfde3 = class (Tabc)
private
..
public
..
..
.....
.....
class function TFactory.Getflag(
Type:TType):Tabc;
begin
Result:=nil;
case AccType of
sfde1:Result:=Tsfde1.Create;
sfde2:Result:=Tsfde2.Create;
sfde3:Result:=Tsfde3.Create;
sfde4:Result:=Tsfde4.Create;
sfde5:Result:=Tsfde5.Create;
sfde6:Result:=Tsfde6.Create;
end;
end;