unsigned
is a data type! And it happens to alias to unsigned int
.
When you’re writing unsigned x;
you are not omitting any data type.
This is completely different from “default int
” which exists in C (but not in C++!) where you really omit the type on a declaration and C automatically infers that type to be int
.
As for style, I personally prefer to be explicit and thus to write unsigned int
. On the other hand, I’m currently involved in a library where it’s convention to just write unsigned
, so I do that instead.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…