2008/09/16 | 先记下一个接口与继承
类别(语言类学习笔记) | 评论(0) | 阅读(14) | 发表于 22:44

IOpenDoor = interface
  function Open: boolean
end;

THome = class(IOpenDoor)
  function Open
end;

TCar = class(IOpenDoor)
  function Open;
end;

var
  AOpen: IOpenDoor;
begin
  if xxx then AOpen := THome.Create
  else AOpen := TCar.Create;
  AOpen.Open();
end;

这个很像:

var
  a:Tstrings
begin
  a:=Tstringlist.create
end;

0

评论Comments