Should I use unsigned integers for counting members?

前端 未结 6 2098
自闭症患者
自闭症患者 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:03

    No, definitely not. Delphi idiom is to use integers here. Don't fight the language. In a 32 bit environment you'll not have more elements in the list, except if you try to build a bitmap.

    Let's be clear: every programmer who is going to have to use your code is going to hate you for using a Cardinal instead of an integer.

提交回复
热议问题