Re: [問題] 請問傳參考到底是什麼?
如果說 C/C++ 沒有 call-by-address, 只有 call-by-value,
個人覺得這樣未免太 cynical 了 @_@"
參數的傳遞模式應該是種抽像的概念, 而不是實際的實作方式.
摘一段 Concepts of Programming Languages, Robert W. Sebesta,
9.5.2.4 的 Pass-by-Reference 來說
(這裡的 reference 是概念上的 reference, 不是C++的reference)
the pass-by-reference method transmits an access path,
usually just an address, to the called subprogram.
(傳參照的方法傳遞一個取存路徑, 通常就是一個位址, 給被呼叫端)
This provides the access path to the cell storing the actual parameter.
(這提供一個儲存真實參數的存取路徑)
Thus the called subprogram is allowed to access the actual parameter
(因此被呼叫的副程式可以取存真實參數)
in the calling program unit. In effect, the actual parameter is
shared with the called subprogram.
(繞來繞去其實都在講同一個東西..||)
--
若要以實作方去說 C/C++ 只存在 call-by-value 的話,
那應該沒有語言可以達到所謂 call-by-reference了吧?
每個東西追根究底還是傳不是value過去.__.?
又或者是不是可以說, 根本就沒有 method 或 function 這種東西,
說穿了還不是 jump ?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.42.112
※ 編輯: cole945 來自: 140.112.42.112 (06/21 22:44)
推
06/21 22:56, , 1F
06/21 22:56, 1F
→
06/21 22:57, , 2F
06/21 22:57, 2F
→
06/21 22:58, , 3F
06/21 22:58, 3F
→
06/21 22:58, , 4F
06/21 22:58, 4F
→
06/21 22:59, , 5F
06/21 22:59, 5F
→
06/21 22:59, , 6F
06/21 22:59, 6F
→
06/21 23:00, , 7F
06/21 23:00, 7F
→
06/21 23:02, , 8F
06/21 23:02, 8F
→
06/21 23:02, , 9F
06/21 23:02, 9F
→
06/21 23:02, , 10F
06/21 23:02, 10F
→
06/21 23:02, , 11F
06/21 23:02, 11F
→
06/21 23:03, , 12F
06/21 23:03, 12F
→
06/21 23:03, , 13F
06/21 23:03, 13F
→
06/21 23:04, , 14F
06/21 23:04, 14F
→
06/21 23:04, , 15F
06/21 23:04, 15F
→
06/21 23:05, , 16F
06/21 23:05, 16F
推
06/21 23:09, , 17F
06/21 23:09, 17F
→
06/21 23:10, , 18F
06/21 23:10, 18F
→
06/21 23:11, , 19F
06/21 23:11, 19F
→
06/21 23:11, , 20F
06/21 23:11, 20F
→
06/21 23:12, , 21F
06/21 23:12, 21F
→
06/21 23:12, , 22F
06/21 23:12, 22F
推
06/21 23:14, , 23F
06/21 23:14, 23F
→
06/21 23:16, , 24F
06/21 23:16, 24F
→
06/21 23:16, , 25F
06/21 23:16, 25F
推
06/21 23:19, , 26F
06/21 23:19, 26F
→
06/21 23:19, , 27F
06/21 23:19, 27F
→
06/21 23:54, , 28F
06/21 23:54, 28F
→
06/21 23:54, , 29F
06/21 23:54, 29F
推
06/22 00:23, , 30F
06/22 00:23, 30F
推
06/22 16:47, , 31F
06/22 16:47, 31F
→
06/22 16:48, , 32F
06/22 16:48, 32F
→
06/22 16:49, , 33F
06/22 16:49, 33F
→
06/22 16:51, , 34F
06/22 16:51, 34F
推
06/22 16:55, , 35F
06/22 16:55, 35F
→
06/22 16:56, , 36F
06/22 16:56, 36F
→
06/22 16:56, , 37F
06/22 16:56, 37F
→
06/22 16:57, , 38F
06/22 16:57, 38F
→
06/22 17:04, , 39F
06/22 17:04, 39F
推
06/22 17:05, , 40F
06/22 17:05, 40F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章