请问怎么在delphi中新建一个单元,用来定义并实现自己定义的函数?
比如我新建一个单元unit2
unit Unit2;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
function test(i:Integer):Integer ;
implementation
function TForm1.test(i: Integer): Integer;
beginend;
end.报错:[Error] Unit2.pas(9): Identifier expected but 'FUNCTION' found
[Error] Unit2.pas(11): Function needs result type
[Error] Unit2.pas(9): Unsatisfied forward or external declaration: 'test'
[Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit2.pas'
比如我新建一个单元unit2
unit Unit2;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
function test(i:Integer):Integer ;
implementation
function TForm1.test(i: Integer): Integer;
beginend;
end.报错:[Error] Unit2.pas(9): Identifier expected but 'FUNCTION' found
[Error] Unit2.pas(11): Function needs result type
[Error] Unit2.pas(9): Unsatisfied forward or external declaration: 'test'
[Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit2.pas'
beginend;
改为
function test(i: Integer): Integer;
beginend;
[Error] Unit1.pas(30): Undeclared identifier: 'test'
[Fatal Error] Project1.dpr(6): Could not compile used unit 'Unit1.pas'