Delphi 接口(5)-接口与类型转换

2021-07-04 04:29

阅读:574

标签:end   接口   span   var   类型转换   code   ati   inter   creat   

//接口与类型转换

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)-接口与类型转换

标签:end   接口   span   var   类型转换   code   ati   inter   creat   

原文地址:https://www.cnblogs.com/YiShen/p/9863007.html


评论


亲,登录后才可以留言!