首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

请教如何在delphi中新建一个单元,用来定义并实现自己定义的函数

2012-03-17 
请问怎么在delphi中新建一个单元,用来定义并实现自己定义的函数?请问怎么在delphi中新建一个单元,用来定义

请问怎么在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;

热点排行