是不是SavingStc:=GetStc;有问题?因为赋值运算符对子类是要重载的。 可以试试这个: procedure sth(SavingStc:TStatistics); begin if SavingStc is TSampleStatistics then TSampleStatistics(SavingStc).Save(-1) else if SavingStc is TComplexStatistic then TComplexStatistic(SavingStc).Save(-1) else if SavingStc is T2DimStatistics then T2DimStatistics(SavingStc).Save(-1) else SavingStc.Save(-1); end;
可以试试这个:
procedure sth(SavingStc:TStatistics);
begin
if SavingStc is TSampleStatistics then
TSampleStatistics(SavingStc).Save(-1)
else if SavingStc is TComplexStatistic then
TComplexStatistic(SavingStc).Save(-1)
else if SavingStc is T2DimStatistics then
T2DimStatistics(SavingStc).Save(-1)
else
SavingStc.Save(-1);
end;