Re: [问题] private继承问题

楼主: JustinHere (良葛格)   2014-07-25 08:08:35
http://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)
Inheritance should not be confused with subtyping.[1] In some languages
inheritance and subtyping agree,[a] while in others they differ; in general
subtyping establishes an is-a relationship, while inheritance only reuses
implementation and establishes a syntactic relationship, not necessarily a
semantic relationship (inheritance does not ensure behavioral subtyping). To
distinguish these concepts, subtyping is also known as interface inheritance,
while inheritance as defined here is known as implementation inheritance.
我们到底是在讨论哪种继承?看来两者都有!
或许该来讨论一下,JLS 定义的是哪种继承才是重点 … XD
以 JLS 着重在 public、protected 的观点,它讲的应该是 interface inheritance,
在 Java 中,inheritance 以 subtyping 来实现,着重在公开外貌,也因此,JLS 中
才会定义 private 不属于被继承的(外貌)。
我花了点时间重新看了整个讨论,重新想了一下自己先前写的:
https://www.ptt.cc/bbs/java/M.1405898364.A.F01.html
找了网络上更多 inheritance 的讨论,我想,我讲的也是从 interface inheritance
角度来看 ...
我多认识了一点东西 … 下次有人问我这个题目时,我又多了一些东西可以嘴砲 …
作者: swpoker (swpoker)   2014-07-25 09:00:00
之前有强迫症会写interface->abstract->class 最少3个后来很懒惰最多只写抽象就好~有需要再抽接口出来
作者: kiwatami (悠游自在)   2014-07-25 21:02:00
感谢你这么认真地回复这个基础的问题 那篇维基我有看过不过还是只知其然 不知其所以然...我想我应该要找个时间把里面关联的项目都看一看才是
楼主: JustinHere (良葛格)   2014-07-26 08:21:00
这个题目不基础…国外也吵过很多轮了…XDDoes subclasses inherit private fields?http://tinyurl.com/oetosjw

Links booklink

Contact Us: admin [ a t ] ucptt.com