delphi中能否让一个子类既继承父类又实现定义好的接口?怎么实现?
时间:2011-08-31
来源:互联网
Delphi(Pascal) code
{父类:汽车类} Tcar = class(TObject) private name : string; Fwheel: Twheel; Fbrake: Tbrake; Fengine: Tengine; Fcarbody: Tcarbody; public function CarPackage(s : string): string; virtual; //组装汽车 end; {接口} interface type carMove = interface function SpeedDown():string; //减速 function ShutDown():string; //停止 function Start():string; //启动 function carspeedUp():string; function StartBrake:string;//启动刹车 end; {子类} uses TcarClass; type TAodiQ7 = class(TCar) private public function CarPackage(s : string): string; override; end;
作者: hhkun0120 发布时间: 2011-08-31
unit Unit3; interface uses SysUtils; type carMove = interface function SpeedDown(): string; //减速 function ShutDown(): string; //停止 function Start(): string; //启动 function carspeedUp(): string; function StartBrake: string; //启动刹车 end; {父类:汽车类} Tcar = class(TObject) private name: string; Fwheel: Twheel; Fbrake: Tbrake; Fengine: Tengine; Fcarbody: Tcarbody; public function CarPackage(s: string): string; virtual; //组装汽车 end; TAodiQ7 = class(TCar, carMove) private protected // interface carMove function SpeedDown(): string; //减速 function ShutDown(): string; //停止 function Start(): string; //启动 function carspeedUp(): string; function StartBrake: string; //启动刹车 public function CarPackage(s: string): string; override; end; implementation { TAodiQ7 } function TAodiQ7.CarPackage(s: string): string; begin end; function TAodiQ7.carspeedUp: string; begin end; function TAodiQ7.ShutDown: string; begin end; function TAodiQ7.SpeedDown: string; begin end; function TAodiQ7.Start: string; begin end; function TAodiQ7.StartBrake: string; begin end; { Tcar } function Tcar.CarPackage(s: string): string; begin end; end.
作者: jayqiang 发布时间: 2011-09-01
Delphi(Pascal) code
//Sysutils是Pascal的一个库 uses Sysutils这个语句的意思就是调用这个库 uses Sysutils;
这个Sysutils 是什么样的一个库?
作者: hhkun0120 发布时间: 2011-09-01
作者: sz_haitao 发布时间: 2011-09-01
[Pascal Error] TAodiA4cls.pas(21): E2003 Undeclared identifier: 'QueryInterface' [Pascal Error] TAodiA4cls.pas(21): E2003 Undeclared identifier: '_AddRef' [Pascal Error] TAodiA4cls.pas(21): E2003 Undeclared identifier: '_Release' [Pascal Error] TAodiA4cls.pas(29): E2008 Incompatible types [Pascal Error] TAodiA4cls.pas(35): E2003 Undeclared identifier: 'Result' [Pascal Fatal Error] CarProject.dpr(15): F2063 Could not compile used unit '..\src\TAodiA4cls.pas'
貌似接口写的不合规定
我到网上先查查
作者: hhkun0120 发布时间: 2011-09-01
能否给几个例子。
Sysutils 是系统工具库
作者: hhkun0120 发布时间: 2011-09-01
Child = class(Parent, Interface....)
作者: dfasri 发布时间: 2011-09-01
作者: hhkun0120 发布时间: 2011-09-01
[Pascal Error] TAodiA4cls.pas(21): E2003 Undeclared identifier: '_AddRef'
[Pascal Error] TAodiA4cls.pas(21): E2003 Undeclared identifier: '_Release'
继承接口,必须实现这3个成员
作者: diecode 发布时间: 2011-09-01
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28