Omitting the datatype (e.g. “unsigned” instead of “unsigned int”)

后端 未结 4 2011
猫巷女王i
猫巷女王i 2021-01-31 08:01

I know that if the data type declaration is omitted in C/C++ code in such way: unsigned test=5;, the compiler automatically makes this variable an int (an unsigned

4条回答
  •  -上瘾入骨i
    2021-01-31 09:07

    As @Konrad Rudolph says, unsigned is a datatype. It's really just an alias for unsigned int.

    As to the question of using unsigned being bad practice? I would say no, there is nothing wrong with using unsigned as a datatype specifier. Professionals won't be thrown by this, and any coding standard that says you have to use unsigned int is needlessly draconian, in my view.

提交回复
热议问题