Re: [問題] private繼承問題

看板java作者 (良葛格)時間9年前 (2014/07/25 08:08), 9年前編輯推噓1(107)
留言8則, 3人參與, 最新討論串17/17 (看更多)
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 角度來看 ... 我多認識了一點東西 … 下次有人問我這個題目時,我又多了一些東西可以嘴砲 … -- 良葛格學習筆記 http://openhome.cc -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.9.216.193 ※ 文章網址: http://www.ptt.cc/bbs/java/M.1406246918.A.ECD.html ※ 編輯: JustinHere (101.9.216.193), 07/25/2014 08:09:34

07/25 09:00, , 1F
之前有強迫症會寫interface->abstract->class 最少3個
07/25 09:00, 1F

07/25 09:01, , 2F
後來很懶惰最多只寫抽象就好~有需要再抽介面出來
07/25 09:01, 2F

07/25 21:02, , 3F
感謝你這麼認真地回覆這個基礎的問題 那篇維基我有看過
07/25 21:02, 3F

07/25 21:03, , 4F
不過還是只知其然 不知其所以然...
07/25 21:03, 4F

07/25 21:05, , 5F
我想我應該要找個時間把裡面關聯的項目都看一看才是
07/25 21:05, 5F

07/26 08:21, , 6F
這個題目不基礎…國外也吵過很多輪了…XD
07/26 08:21, 6F

07/26 08:22, , 7F
Does subclasses inherit private fields?
07/26 08:22, 7F

07/26 08:22, , 8F
文章代碼(AID): #1JqQ06xD (java)
討論串 (同標題文章)
文章代碼(AID): #1JqQ06xD (java)