程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi語言學習5-函數和方法(2)

Delphi語言學習5-函數和方法(2)

編輯:Delphi

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;
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved