就拿TComponent来说吧。
TComponent = class(TPersistent, IInterface, IInterfaceComponentReference)
......
    function QueryInterface(const IID: TGUID; out Obj): HResult; virtual; stdcall;
    function _AddRef: Integer; stdcall;
    function _Release: Integer; stdcall;
......//其它部分不写了。
end;
而在system.pas中:
type
  IInterface = interface
    ['{00000000-0000-0000-C000-000000000046}']
    function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
    function _AddRef: Integer; stdcall;
    function _Release: Integer; stdcall;
  end;//
不明白在TComponent中为什么还要再声明一遍???不是已经继承了该接口了么?

解决方案 »

  1.   

    不明白在TComponent中为什么还要再声明一遍???
    是说
    function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
        function _AddRef: Integer; stdcall;
        function _Release: Integer; stdcall;
    三个方法吗。
    TComponent中可不是声明呢,它是要实现这三个方法。
    接口声明的方法,要在实现该接口的类中实现。
      

  2.   

    因为TComponent继承了该接口,所以TComponent就必需实现这个接口的方法,而不是再申明一遍。
      

  3.   

    system.pas
    看不见实现代码,只是声明TComponent
    在这里实现
      

  4.   

    楼上各位,不知是我没明白你回答的,还是你没明白我问什么?接口本身只声明方法,应该在TComponent中实现,,可是实现的地方应该是在下面吧?->TComponent._AddRef;等等。而在类定义中那三行难道不是又声明了一遍???