读书人

请教如何在delphi中新建一个单元用来

发布时间: 2012-03-17 19:06:27 作者: rapoo

请问怎么在delphi中新建一个单元,用来定义并实现自己定义的函数?
请问怎么在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;
begin

end;
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'

[解决办法]
function TForm1.test(i: Integer): Integer;
begin

end;
改为
function test(i: Integer): Integer;
begin

end;

读书人网 >.NET

热点推荐