This error message appears in your delphi program when the declaration of a procedure, function, method, function Object() { [native code] }, or destructor differs from its previous (forward) declaration.
This error message also appears when you attempt to override a virtual method, but the overriding method has a different parameter list, calling convention, and so on.
program Produce; type MyClass = class procedure Proc(Inx: Integer); function Func: Integer; procedure Load(const Name: string); procedure Perform(Flag: Boolean); constructor Create; destructor Destroy(Msg: string); override; (*<-- Error message here*) class function NewInstance: MyClass; override; (*<-- Error message here*) end; procedure MyClass.Proc(Index: Integer); (*<-- Error message here*) begin end; function MyClass.Func: Longint; (*<-- Error message here*) begin end; procedure MyClass.Load(Name: string); (*<-- Error message here*) begin end; procedure MyClass.Perform(Flag: Boolean); cdecl; (*<-- Error message here*) begin end; procedure MyClass.Create; (*<-- Error message here*) begin end; function MyClass.NewInstance: MyClass; (*<-- Error message here*) begin end; begin end.
As you can see, there are several possible causes for this error message to be displayed.
program Solve; type MyClass = class procedure Proc(Inx: Integer); function Func: Integer; procedure Load(const Name: string); procedure Perform(Flag: Boolean); constructor Create; destructor Destroy; override; (*No parameters*) class function NewInstance: TObject; override; (*Result type *) end; procedure MyClass.Proc(Inx: Integer); (*Parameter name *) begin end; function MyClass.Func: Integer; (*Result type *) begin end; procedure MyClass.Load(const Name: string); (*Parameter kind *) begin end; procedure MyClass.Perform(Flag: Boolean); (*Calling convention*) begin end; constructor MyClass.Create; (*constructor*) begin end; class function MyClass.NewInstance: TObject; (*class function*) begin end; begin end.
To determine what is different between the two, carefully compare the ‘previous declaration’ with the one that causes the error.
Leave a Reply