討論串[請益] for迴圈 i++ or ++i ?
共 6 篇文章
首頁
上一頁
1
2
下一頁
尾頁

推噓4(4推 0噓 4→)留言8則,0人參與, 最新作者adrianshum (Alien)時間18年前 (2007/12/10 22:33), 編輯資訊
0
0
0
內容預覽:
由於 postfix ++ (或 --) return 的值是. increment/decrement 前的值。假設現在用的. 是一個 class 而非一般的 integer:. class MyClass {. public:. MyClass& operator++(); // prefix
(還有299個字)

推噓1(1推 0噓 1→)留言2則,0人參與, 最新作者solonchuang (企鵝寶寶)時間18年前 (2007/12/10 22:05), 編輯資訊
0
0
2
內容預覽:
畢竟用了非常久的i++,. 追根究底請教一下, 為什麼 ++i 比較好?. --. 內有閃光 連寶寶都有了. http://www.wretch.cc/album/isoldeliu. http://www.wretch.cc/album/solonchuang. --. 發信站: 批踢踢實業坊

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者adrianshum (Alien)時間18年前 (2007/12/10 16:39), 編輯資訊
0
0
0
內容預覽:
原因大概因為 i++ 看起來比較順眼,. 還有其實寫了很久程式的人也不太會留意. 這個分別而已. Alien. --. 發信站: 批踢踢實業坊(ptt.cc). ◆ From: 202.155.236.82.

推噓5(5推 0噓 2→)留言7則,0人參與, 最新作者bluewindb (damn)時間18年前 (2007/12/10 15:52), 編輯資訊
0
0
0
內容預覽:
覺得有點好奇的是. 如果用++i會比較好. 那為什麼教c++的書在寫迴圈章節的時候. 都用i++的方式來表示呢?XD. --. 發信站: 批踢踢實業坊(ptt.cc). ◆ From: 140.138.149.89.

推噓0(0推 0噓 2→)留言2則,0人參與, 最新作者adrianshum (Alien)時間18年前 (2007/12/10 14:49), 編輯資訊
0
0
0
內容預覽:
當然不是 scripting langauge 才有分別.. C++ 中, 如果 for 中的不是 int, 而是 iterator,. ++i 和 i++ 就可能會有明顯的分別了.. 所以可以的話, 習慣用 ++i 會比較好. alien. --. 發信站: 批踢踢實業坊(ptt.cc). ◆
首頁
上一頁
1
2
下一頁
尾頁