gpt4 book ai didi

java - 迈耶在java中的实现继承

转载 作者:行者123 更新时间:2023-12-01 08:56:15 25 4
gpt4 key购买 nike

谁能举个例子 Meyers Implementation inheritance在 Java 中,链接中的书是关于埃菲尔铁塔的,但我需要一个 Java 示例。

我知道java不支持多重继承,那我实现一个接口(interface),扩展一个类,是不是可以称之为实现继承?

另外,实现继承是否必须有两个父类?

最佳答案

本书中的定义在这里进行了复述:

Definition: implementation inheritance Structural inheritance applies if B obtains from A a set of features (other than constant attributes and once functions) necessary to the implementation of the abstraction associated with B. Both A and B must be effective.

A 类和 B 类不得延期。当通过非抽象类 B 扩展非抽象 Java 类 A 时就是这种情况。

Definition: reification inheritance Reification inheritance applies if A represents a general kind of data structures, and B represents a partial or complete choice of implementation for that data structure. A is deferred; B may still be deferred, leaving room for further reification through its own heirs, or it may be effective.

类 A 是延迟的,因此在实现 Java 接口(interface) A 或扩展 Java 接口(interface) A(新接口(interface)将是 B)时会出现这种情况

您指定的情况(在 Java 中实现接口(interface)和扩展非抽象类)是这两者的组合。文字在这里说得很清楚:

A common case is what will be called the "marriage of convenience", based on multiple inheritance, where one parent provides the specification (reification inheritance) and the other the implementation (implementation inheritance).

关于java - 迈耶在java中的实现继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20129669/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com