說說大家編程時最容易犯的錯誤
文章內容
偶做C++的,最麻煩的就是指針。。。但又是最強大的,很多人對指針敬而遠之,但是對有assembly編程經驗的人來說,一切又那麼自然
分享: | 分享到微信 |
文章評論
3M | 評論 由於寫多了php程序,很容易在javascript的變量前面加上$
2008-11-10 09:47:51 | 引用 |
Re: 說說大家編程時最容易犯的錯誤
最喜歡把 if(i == 0)寫成if (i = 0) 2008-11-10 09:57:17 | 引用 |
SARS |
7thGuest | Re: 說說大家編程時最容易犯的錯誤
most today's compiler will issue warning of this. 2008-11-10 09:59:07 | 引用 |
無題 C++做多了,基本上不出什麼錯。
但做php, perl 的編譯不強的程序時,經常犯的錯是忘了變量前加$,這個還好,程序會出錯。最怕變量名引用時寫錯了,如大小寫,有無下劃線等,程序不會出錯,就不正確結果,調試時常常給弄瘋了。 2008-11-10 10:01:00 | 引用 |
deerlake |
webdriver | 無題 又一陣狂用STL,vector,list等等container,結果發現也不是那麼容易用的,每個class想放進去,還得自己實現copy constructor
2008-11-10 10:01:07 | 引用 |
Re: 說說大家編程時最容易犯的錯誤
我從來都這樣寫: if(0 == i) 可以防止出錯。 2008-11-10 10:01:56 | 引用 |
deerlake |
7thGuest | Re: 說說大家編程時最容易犯的錯誤 2008-11-10 10:04:18 | 引用 |
Re: 說說大家編程時最容易犯的錯誤 if(0 == i)
It's good until somebody complain the readability. 2008-11-10 12:18:28 | 引用 |
許萬克 |
bigbigloser | Re: 說說大家編程時最容易犯的錯誤
then you can complain that the reader don't have good coding behavior. 2008-11-10 12:20:50 | 引用 |
無題 Pass by ref in C#. (I don't make this kind of mistake anymore )
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. 2008-11-10 12:28:19 | 引用 |
bigbigloser |