Signed vs. unsigned integers for lengths/counts

后端 未结 4 629
感情败类
感情败类 2020-12-05 02:53

For representing a length or count variable, is it better to use signed or unsigned integers?

It seems to me that C++ STL tends to p

4条回答
  •  温柔的废话
    2020-12-05 03:34

    If you aren't designing a reusable library (in .NET terms, e.g. a VB.NET project consumes your C# class library) then pick what works for you. Of course if you are creating any kind of DLL, and it's feasible your library could be used in a project with a different language (again, VB.NET comes to mind) then you need to be mindful of the non-compliant types (unsigned).

提交回复
热议问题