在mainForm中要TfrmImport.Create(nil,'key')来传递一个key给frmImort,结果总是有错误或者告警原来以前很简单的东西:
 constructor Create(AOwner: TComponent;Key:string);override;提示
[Error] untLocate.pas(18): Declaration of 'Create' differs from previous declaration
[Error] untLocate.pas(32): Unknown directive: 'override'
不知道了原因,谁HELP一下(最后即个最简单的工程试一下,我也以为非常简单,结果总是不对)

解决方案 »

  1.   

    不好意思,错了
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
      private
        { Private declarations }  public
        constructor Create(AOwner: TComponent); override;
      published    { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    { TForm1 }{ TForm1 }constructor TForm1.Create(AOwner: TComponent);
    begin
      inherited;end;end.
      

  2.   

    我是想用这种方式创建新的FormTfrmImport.create(Application,'this is the str par)
    结果在override(overload) create方法的时候老是提示有错误!或者warnings上面的构造函数的参数没有改变,自然是不会有错误的了 constructor Create(AOwner: TComponent); override;
      

  3.   

    constructor Create(AOwner: TComponent;Key:String); override; 注意原文参数个数不对.
    constructor TForm1.Create(AOwner: TComponent;key:String);
    begin
      inherited;
      self.caption := Key ;
    end;
      

  4.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
      private
        { Private declarations }
      public
      constructor Create(AOwner: TComponent;Key:String); override;
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}constructor TForm1.Create(AOwner: TComponent;key:String);
    begin
      inherited;
      self.caption := Key ;
    end;
    end.
    编译:
    [Error] Unit1.pas(14): Declaration of 'Create' differs from previous declaration
    [Error] Unit1.pas(27): Incompatible types
    [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
      

  5.   

    把Override去掉, 因Create不是虚函数
    constructor Create(AOwner: TComponent;Key:String); constructor TForm1.Create(AOwner: TComponent;key:String);
    begin
      self.caption := Key ;
      inherited Create(self);
      
    end;
      

  6.   

    把Override去掉, 因Create不是虚函数, 加上Overload
    constructor Create(AOwner: TComponent;Key:String); Overload;constructor TForm1.Create(AOwner: TComponent;key:String); 
    begin
      self.caption := Key ;
      inherited Create(self);
      
    end;数
      

  7.   

    丢了个Overload
    constructor Create(AOwner: TComponent;Key:String); Overload;
      

  8.   

    说Form1是要动态生成的,Form2是主窗体,调用方法:
    procedure TForm2.Button1Click(Sender: TObject);
    begin
      TForm1.Create(self,'hello');
      Form1.Show;
    end;
    Form1的CREATE方法:
    begin
      self.caption := Key ;
      inherited Create(self);
    end;
    TForm的Create继承自TCustomForm
    一,如果声明为:constructor Create(AOwner: TComponent;Key:String); Overload;
    编译错误是:
    [Warning] Unit1.pas(15): Method 'Create' hides virtual method of base type 'TCustomForm'
    在TForm2.Button1Click(Sender: TObject);的时候将出现:access violation .....二,如果声明为:constructor Create(AOwner: TComponent;Key:String); Override;
    [Error] Unit1.pas(14): Declaration of 'Create' differs from previous declaration三,如果是constructor Create(AOwner: TComponent;Key:String);
    和一的情况一样
    真怀疑是不是这个TCustomform的create是不是有点特别
      

  9.   

    constructor Create(AOwner: TComponent;Key:String); reintroduce;overload;
    constructor TForm2.Create(AOwner: TComponent; Key: String);
    begin
     TForm1(AOwner).caption := Key ;
      inherited Create(AOwner);end;
    成功!接分
      

  10.   

    不要在Create里面用self, 因为在执行inherited Create(AOwner);之前,你的对象还没有创建成功,所以用self,就会出现地址越界, 这是问题的关键!