[問題] 關於 method overloading
各位板友好
目前在學習 method overloading,已經了解到不同 method 要 overloading 的前提是:
1. method的名稱要相同
2. 參數的型別順序或種類不同
另外,看到一句話有點不解
Internally, the compiler uses longer method names that include
the original method name,
the types of each parameter and the exact order of the parameters
to determine whether the methods in a class are unique in that class.
解讀這句話的意思是:
編譯器實際的作法,是用較長的 method 簽名,來判定
類別中的其餘 method 是否為唯一。
但還是想多了解一些細節
我可以理解,不管程式中有無呼叫這些 overloaded method,編譯器也應該會去
比較不同 method,來確定類別中一定不會發生兩個以上的 method 有著相同簽名
但所謂的「longer」的意思是,有著較多參數的 method 嗎?
如果有板友能再多解釋一下編譯器的實際判定作法就太好了
謝謝~
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.162.91.203
※ 文章網址: https://www.ptt.cc/bbs/java/M.1457894092.A.9DD.html
推
03/14 03:32, , 1F
03/14 03:32, 1F
→
03/14 03:33, , 2F
03/14 03:33, 2F
→
03/14 03:33, , 3F
03/14 03:33, 3F
→
03/14 03:34, , 4F
03/14 03:34, 4F
→
03/14 03:35, , 5F
03/14 03:35, 5F
→
03/14 03:36, , 6F
03/14 03:36, 6F
→
03/14 03:37, , 7F
03/14 03:37, 7F
→
03/14 03:37, , 8F
03/14 03:37, 8F
→
03/14 03:40, , 9F
03/14 03:40, 9F
→
03/14 03:45, , 10F
03/14 03:45, 10F
※ 編輯: edash (1.162.91.203), 03/14/2016 03:45:54
→
03/14 12:31, , 11F
03/14 12:31, 11F
→
03/14 22:04, , 12F
03/14 22:04, 12F
→
03/14 22:06, , 13F
03/14 22:06, 13F
→
03/14 22:06, , 14F
03/14 22:06, 14F
→
03/14 22:12, , 15F
03/14 22:12, 15F
→
03/14 22:12, , 16F
03/14 22:12, 16F
→
03/16 07:12, , 17F
03/16 07:12, 17F
java 近期熱門文章
PTT數位生活區 即時熱門文章