*********怎么判断父类接口是否是实现了子类接口*********(100分)

  • 主题发起人 downlder
  • 开始时间
D

downlder

Unregistered / Unconfirmed
GUEST, unregistred user!
用对象没有什么问题,

var
a: TAnimal;
b: TBird;
begin
.....
if a is TBird then
(a as TBird).Fly;
end;

接口就不行了
var
a: IAnimal;
b: IBird;
begin
.....
if Supports(a, IBird, b) then
//if a is IBird then
b.Fly;
end;
 
var
Unk:IUnKnown;

a.QueryInterface(IID_Bird,b);
if b <> nil then
(b as IBird).Fly;
 
会提示接口不支持, QueryInterface和Supports的功能是一样的
 
贴完整的代码
 
顶部