Should one ever declare a variable as an unsigned int if they don\'t require the extra range of values? For example, when declaring the variable in a for loop, if you know i
int is the general purpose integer type. If you need an integer, and int meets your requirements (range [-32767,32767]), then use it.
If you have more specialized purposes, then you can choose something else. If you need an index into an array, then use size_t. If you need an index into a vector, then use std::vector. If you need specific sizes, then pick something from
I can't think of any good reasons to use unsigned int. At least, not directly (size_t and some of the specifically sized types from may be typedefs of unsigned int).