Should I use unsigned integers for counting members?

前端 未结 6 1955
自闭症患者
自闭症患者 2021-02-04 14:25

Should I use unsigned integers for my count class members?

Answer

For example, assume a class

TList  = class
private
           


        
6条回答
  •  时光说笑
    2021-02-04 15:07

    Boundary conditions frequently present problems. Allowing for a type that can go negative may just shift the issue. Perhaps it shifts it in a way that's easier to debug, perhaps not. I started off using integers for counting loops like that, but later on switched to cardinals to help me catch errors.

提交回复
热议问题