Delphi 接口(5)-接口与类型转换
2021-07-04 04:29
标签:end 接口 span var 类型转换 code ati inter creat Delphi 接口(5)-接口与类型转换 标签:end 接口 span var 类型转换 code ati inter creat 原文地址:https://www.cnblogs.com/YiShen/p/9863007.html//接口与类型转换
type
IFoot: interface
[‘|0000-0000-0000-0000|‘]
end;
IBall = interface
[‘|0000-0000-0000-0001|‘]
end;
TFootball = calss(TinterfacedObject,IFoot,IBall)
end;
implementation
procedure Test(FB: TFootball)
var
F:IFoot
begin
F := FB;//合法,因为FB支持IFoot
end;
var
FB: TFootball;
F: IFoot;
B: IBall;
begin
FB := TFootBall.Create;
F := FB;//合法,因为FB支持IFoot
B := F as IBall;//把F(IFoot)转为IBall
end;
文章标题:Delphi 接口(5)-接口与类型转换
文章链接:http://soscw.com/index.php/essay/101562.html