Delphi 接口-接口和多重继承
Posted yishen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Delphi 接口-接口和多重继承相关的知识,希望对你有一定的参考价值。
unit uSayHello; interface uses SysUtils, Windows, Messages, Greaphics, Controls, Forms, Dialogs; type ISeakChinese = interface(IInterface) function SayHello: string; end; ISpeakEndlish = interface(IInterface) function SayHello: string; end; TMan = class(TInterfacedObject) private FName: string; public property Name: string read FName write FName; end; TChinese = class(TMan,ISpeakChinese) private function SayHello: string; end; TAmerican = class(TMan,ISpeakEndlish) function SayHello: string; end; TAmericanChinese = class(TMan,ISpeakChinese,ISpeakEndlish) public constructor create; function SayHello: string; end; implementation function TAmerican.SayHello: string; begin result := ‘Hello!‘; end; function TChinese.SayHello: string; begin result := ‘你好‘; end; function TAmericanChinese.create; begin name := ‘Tom Wang‘; end; function TAmericanChinese : string; var Dad:ISpeakChinese; Mum:ISpeakEndlish; begin Dad := TChinese.create; Mum := TAmerican.create; result := Dad.SayHello + Mum.SayHello; end; end.
以上是关于Delphi 接口-接口和多重继承的主要内容,如果未能解决你的问题,请参考以下文章