自定义的类a,create,初始化参数 x:=1;//顺序1
b继承a, create参数y:=2;//顺序2
c继承b, create  参数bitmap:=tbitmap.create;//顺序3现在创建实例 cc:=t.create;
析构时,想按顺序1,2,3执行,
 试了几次,不能肯定自己是对的,
请delphi高手指导

解决方案 »

  1.   

    t.create?t是什么类型?type
      a = class
        public
          x: Integer;
          constructor Create(param_x: Integer); 
      end;  b = class(a)
        public
          y: Integer;
          constructor Create(param_x: Integer;param_y: Integer); //
      end;  c = class(b)
        public
          bitmap: TBitmap;
          constructor Create(param_x: Integer;param_y: Integer;aBitmap: TBitmap); 
      end;implementationconstructor a.Create(param_x: Integer);
    begin
      Inherited Create;
      x := Param_x;
    end;constructor b.Create(param_x: Integer;param_y: Integer);
    begin
      Inherited Create(param_x);
      y := Param_y;
    end;constructor c.Create(param_x: Integer;param_y: Integer;aBitmap: TBitmap);
    begin
      Inherited Create(param_x,param_y);
      Bitmap := aBitmap;
    end;
    var
      cc: c;
    begin
      cc := c.Create(1,2,TBitmap.Create);
    end;
      

  2.   

    type
      a = class
        public
          x: Integer;
          constructor Create; virtual;//定义为虚函数
      end;  b = class(a)
        public
          y: Integer;
          constructor Create;override; //覆盖虚函数
      end;  c = class(b)
        public
          bitmap: TBitmap;
          constructor Create;override; //覆盖虚函数
      end;implementationconstructor a.Create;
    begin
      Inherited Create;
      x := 1;
    end;constructor b.Create;
    begin
      Inherited Create;
      y := 2;
    end;constructor c.Create;
    begin
      Inherited Create;
      Bitmap := TBitmap.Create;
    end;
    var
      cc: c;
    begin
      cc := c.Create;
    end;