delphi語言教程 delphi中接口的定義和使用?
delphi中接口的定義和使用?Define interface idemotypeidemo=interface function a(I:integer):integerend接口中的方法不能有方
delphi中接口的定義和使用?
Define interface idemotypeidemo=interface function a(I:integer):integerend接口中的方法不能有方法體,只能有聲明。然后可以使用接口對象或繼承接口typetdemo=class(tcomponent,IDEO)publicfunctiona(I:integer):integerend,然后構(gòu)造functiontdemo。A(I:integer):integerbeginresult:=I*2end表示類中方法的方法體。也可以將對象轉(zhuǎn)換為接口,例如:變量impl:IDemoTImpl:tDemoBeginTempl:=TDemo.創(chuàng)建(nil)IImpl:=IImpl(TImpl)end
如果您說“Delphi接口標志”,它是指接口的唯一標識號。方法如下:
1。在delphiide中,按Ctrl-Shift-g鍵為接口生成新的guid。
2. 可以使用函數(shù)createguid生成guid。示例代碼如下:函數(shù)getguid:String var LTEP:tguid begin createguid(LTEP)result:=guidtostring(LTEP)end