delphi继承form

  TFrmBase = class(TForm)
    procedure FormShow(Sender: TObject);
  end;
procedure TFrmBase.FormShow(Sender: TObject);
begin
   ShowMessage('base show');
end;

 

type
  TFrmBase14 = class(TFrmBase)procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

 

procedure TFrmBase14.FormShow(Sender: TObject);
begin
  inherited;
ShowMessage('child show');
end;

没有inherited;就不会调用父类的方法。

 

http://blog.csdn.net/foreverhuylee/article/details/37907817

 

    class t0
    {
    public:
           int a;

        void fun() {a++;
        }
    };

    class t1 :public t0
    {
    public:

        //int a;

        void fun() {t0::fun();

            a = a * 2;
        }
    };

    t1 t;
    t.a = 2;
    t.fun();
    t.a = 2;

调用父类方法必须明确写上。t0::fun();

posted on 2017-03-15 13:56  lypzxy  阅读(365)  评论(0编辑  收藏  举报