我有一个如下结构的类:
TCommonProperties = class(TObject)
  protected
    procedure methodMake; virtual;
end;TParent = class(TObject)
  public
    property CommonProperties: TCommonProperties read ... write ...;
end;TChild = class(TParent)
  published
    property CommonProperties;
end;这时,我写一个新类,继承TChild:
TMyClass = class(TChild)
end;在TMyClass中,我要覆盖methodMake,可以做到吗?如果可以,该如何做?
谢谢

解决方案 »

  1.   


    TMyClass = class(TChild)
      protected
        procedure methodMake; override;
    end;
      

  2.   

    TMyClass = class(TChild)
      protected
        procedure methodMake; 
    end;
    就可以了,因为你没有继承TCommonProperties类,继承用overload
      

  3.   

    对用override关键字重写过程吧!
      

  4.   

    ...
    procedure methodMake; overload;
    ...
      

  5.   

    考,又被楼主带笼子了。不是TCommonProperties的子类,没有办法覆盖的。
    若覆盖,则应该:
    TCommonProperties = class(TObject)
      protected
        procedure methodMake; virtual;
    end;TParent = class(TCommonProperties )
      public
        property CommonProperties: TCommonProperties read ... write ...;
    end;TChild = class(TParent)
      published
        property CommonProperties;
    end;TMyClass = class(TChild)
      protected
        procedure methodMake; override;end;
      

  6.   

    TMyClass = class(TChild)
      protected
        procedure methodMake; 
    end;
    就可以了,因为你没有继承TCommonProperties类,继承用overload
      

  7.   

    不是TCommonProperties的子类,没有办法覆盖的。
    若覆盖,则应该:
    TCommonProperties = class(TObject)
      protected
        procedure methodMake; virtual;
    end;TParent = class(TCommonProperties )
      public
        property CommonProperties: TCommonProperties read ... write ...;
    end;TChild = class(TParent)
      published
        property CommonProperties;
    end;TMyClass = class(TChild)
      protected
        procedure methodMake; override;end;