說說大家編程時最容易犯的錯誤

文章內容

偶做C++的,最麻煩的就是指針。。。但又是最強大的,很多人對指針敬而遠之,但是對有assembly編程經驗的人來說,一切又那麼自然
QR Code
請用微信 掃一掃 掃描上面的二維碼,然後點擊頁面右上角的 ... 圖標,然後點擊 發送給朋友分享到朋友圈,謝謝!
分享:
分享到微信

文章評論

SARS
Re: 說說大家編程時最容易犯的錯誤
deerlake 寫道:

我從來都這樣寫:

if(0 == i)

可以防止出錯。


呵呵,i == 0只是個例子,多數時候出錯是等號兩邊都是變量。

2008-11-10 12:40:59 | 引用
無題
C語言數組和指針邊界最容易出錯,導致內存泄漏最麻煩。

2008-11-11 00:28:17 | 引用
rainfly
白茫茫
無題
最容易犯的錯誤是自認為很簡單,而不去測試所有的case。

2008-11-11 15:16:36 | 引用
無題
白茫茫 寫道:
最容易犯的錯誤是自認為很簡單,而不去測試所有的case。

我就不從不test...
客戶找到我再說。。。

2008-11-21 22:21:30 | 引用
nessus
voice
無題
bigbigloser 寫道:
Pass by ref in C#. (I don't make this kind of mistake anymore icon_smile.gif )

1. MyMethod1(MyClass obj)
{
MyClass localObj ......

obj = localObj;
}
2. MyMethod2(ref MyClass obj)
{
MyClass localObj ......

obj = localObj;
}

If obj is not null, MyMethod1 and MyMethod2 will give you the same result.

If obj is null, after call MyMethod1, obj is still null. but MyMethod2 will give you obj you want.


為什麼obj非空的時候莫有區別?

2008-11-22 09:17:59 | 引用
上一頁12下一頁

發表評論

個人簡介

webdriver
『人生游戲,游戲人生』


日志分類
最新日志
此功能已被空間主人關閉
博客搜索
 
快速導航
友情鏈接
此功能已被空間主人關閉
博客統計
點擊: 649561
帖子數量: 691
開辟個人空間: 2008-10-15
最後更新: 2018-05-11
左鄰右舍
 
 
 
 
 
The images, logos, trademarks used on this site and all forwarded content are the property of their respective owners.
We are not responsible for comments posted by our visitors, as they are the property of the poster.
All other content of this website is copyrighted by 加西網

Private Policy | moonlake oblog skin

加西網為北美中文網傳媒集團旗下網站