idemo塞爾維亞語 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)結(jié)束