3.函數聲明
//先聲明後實現
function Calculate(X, Y: Integer): Real; forward;
function Calculate;
... { declarations }
begin
... { statement block }
end;
//擴展聲明
//1
function printf(Format: PChar): Integer; cdecl; varargs;
//2 Linking to Object Files
{$L BLOCK.OBJ}
procedure MoveWord(var Source, Dest; Count: Integer); external;
procedure FillWord(var Dest; Data: Integer; Count: Integer); external;
//3 Importing Functions from LibrarIEs
function SomeFunction(S: string): string; external 'strlib.dll';
//The following declaration imports a function from user32.dll (part of the Win32 API).
function MessageBox(HWnd: Integer; Text, Caption: PChar; Flags: Integer): Integer; stdcall; external 'user32.dll' name 'MessageBoxA';
4.函數重載
function Divide(X, Y: Real): Real; overload;
begin
Result := X/Y;
end
function Divide(X, Y: Integer): Integer; overload;
begin
Result := X div Y;
end;