Delphi - 从类和接口继承(适配器模式)?
我正在尝试执行 GoF 适配器模式,在 C# 示例中,我遵循的 Adapter 类继承了原始类和一个适配接口。 据我所知,在Delphi(2007)中,这是不可能的,或者是吗?因为如果一个类继承一个接口,它需要从 TInterfacedObject 继承,并且由于 Delphi 不允许多个类继承,这就是故事的结尾。我无法同时继承自定义类和接口。
我说得对吗?
谢谢。
我已经在 http://delphipatterns.blog.com/2011/ 上实现了此模式02/22/装饰器-5/
I am trying to do the GoF adapter pattern and in the C# example that I am following the Adapter class is inheriting the original class and an adapting interface.
In Delphi (2007), as far as I know, this is not possible, or is it? Cause if a class is inheriting an interface, it needs to inherit from TInterfacedObject and since Delphi doesn't allow multiple class inheritance, that is the end of story. I cannot inherit from a custom class and an interface at the same time.
Am I correct?
Thank you.
I have implemented this pattern on http://delphipatterns.blog.com/2011/02/22/decorator-5/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,它不正确。您可以向任何您喜欢的类添加接口,如下所示:
No that it not correct. You can add an interface to any class you like as follows: