怎样使用另一个单元中的函数?
我想把所有的自定义函数放在一个单元文件中然后
在别的单元中
uses 自定义函数单元;
直接使用自定义函数;
例:
————————————————————————
unit Unit2;
interface
implementation
function max(x,y:integer):integer;
var
tmp:integer;
begin
tmp:=x;
if y> x then tmp:=y;
Result:=tmp;
end;
end.
————————————————————
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=IntToStr(max(12,16));
end;
end.
但总是:
[Error] Unit1.pas(30): Undeclared identifier: 'max'